<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Robson Porto</title>
    <description>The latest articles on DEV Community by Robson Porto (@robbporto).</description>
    <link>https://dev.to/robbporto</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F92517%2Fe152cdcf-fe25-4b59-b704-ce8d93b3547e.jpeg</url>
      <title>DEV Community: Robson Porto</title>
      <link>https://dev.to/robbporto</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/robbporto"/>
    <language>en</language>
    <item>
      <title>Reshort - looking for opinions and contributors!</title>
      <dc:creator>Robson Porto</dc:creator>
      <pubDate>Wed, 17 Oct 2018 00:03:47 +0000</pubDate>
      <link>https://dev.to/robbporto/reshort---looking-for-opinions-and-contributors-2f2p</link>
      <guid>https://dev.to/robbporto/reshort---looking-for-opinions-and-contributors-2f2p</guid>
      <description>&lt;p&gt;&lt;a href="https://github.com/robbporto/reshort"&gt;Reshort - write less in your action creators!&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;Hi, everyone! I developed this simple little lib (my first lib!) to help me reduce some repetition in my action creators. I have some ideas of new implementations and I just want to see if anyone is interested in this at all or find this project interesting and useful. If you have any constructive critiques I would be very pleased to hear it. If you have some interest in the project and can help, it would be awesome!&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem:
&lt;/h2&gt;

&lt;p&gt;Let's say that I want to fetch a list of books. Using redux, I have to create three actions creators:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;the first one is the "REQUEST";&lt;/li&gt;
&lt;li&gt;the second one is the "SUCCESS";&lt;/li&gt;
&lt;li&gt;the third one is the "FAIL".&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now let's say that I want to fetch a list of authors. Or a list of users. Or a list of bookmarks... This pattern of REQUEST-SUCCESS-FAIL can become very repetitive and verbose.&lt;/p&gt;

&lt;h2&gt;
  
  
  The solution
&lt;/h2&gt;

&lt;p&gt;Using &lt;code&gt;reshort&lt;/code&gt; you can create one "complete action creator" using one line, instead of three. Like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;reshort&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;reshort&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;productsActions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;reshort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Products&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;productsActions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;request&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// {&lt;/span&gt;
&lt;span class="c1"&gt;//   type: "GET_PRODUCTS"&lt;/span&gt;
&lt;span class="c1"&gt;// }&lt;/span&gt;

&lt;span class="nx"&gt;productsActions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;success&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;123&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="c1"&gt;// {&lt;/span&gt;
&lt;span class="c1"&gt;//   type: "GET_PRODUCTS_SUCCESSFUL",&lt;/span&gt;
&lt;span class="c1"&gt;//   payload: { test: 123 }&lt;/span&gt;
&lt;span class="c1"&gt;// }&lt;/span&gt;

&lt;span class="nx"&gt;productsActions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fail&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;error&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="c1"&gt;// {&lt;/span&gt;
&lt;span class="c1"&gt;//   type: "GET_PRODUCTS_FAILURE",&lt;/span&gt;
&lt;span class="c1"&gt;//   payload: { test: "error" }&lt;/span&gt;
&lt;span class="c1"&gt;// }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>hacktoberfest</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
