<?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: Redux Cool</title>
    <description>The latest articles on DEV Community by Redux Cool (@redux-cool).</description>
    <link>https://dev.to/redux-cool</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%2Forganization%2Fprofile_image%2F4014%2Fbd5a9293-69b2-4884-a373-b22244897da8.png</url>
      <title>DEV Community: Redux Cool</title>
      <link>https://dev.to/redux-cool</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/redux-cool"/>
    <language>en</language>
    <item>
      <title>Redux-Cool Philosophy</title>
      <dc:creator>Ruben Arushanyan</dc:creator>
      <pubDate>Wed, 28 Apr 2021 18:23:47 +0000</pubDate>
      <link>https://dev.to/redux-cool/redux-cool-philosophy-18jp</link>
      <guid>https://dev.to/redux-cool/redux-cool-philosophy-18jp</guid>
      <description>&lt;p&gt;In this article, I am talking about the main problems which we usually face when we use Redux in complex projects. I will also talk about the new &lt;a href="https://redux-cool.js.org" rel="noopener noreferrer"&gt;Redux-Cool&lt;/a&gt; library, with the help of which we can solve those problems. I'm convinced that many developers using Redux need a similar article.&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;As we know &lt;strong&gt;Redux&lt;/strong&gt; is a predictable state container for JavaScript apps. Below you can find the architecture of Redux.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fredux-cool.js.org%2Fimg%2Fredux-diagram.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fredux-cool.js.org%2Fimg%2Fredux-diagram.png" alt="redux architecture diagram"&gt;&lt;/a&gt;&lt;br&gt;
As can be seen from the diagram above, we have a &lt;strong&gt;store&lt;/strong&gt; where our &lt;strong&gt;state data&lt;/strong&gt; is stored, and if we want to change something in the state, we must create an &lt;strong&gt;action object&lt;/strong&gt; which will contain all the information on how we need to change the state. Afterward, we need to dispatch the action object to the reducer. The reducer must receive the action object and based on that it will figure out what to change and how to make that change. This is how the state management works in Redux. Redux as a state management concept is really good because it is predictable - we are not changing the state directly.&lt;/p&gt;

&lt;p&gt;As we have already mentioned, Redux is very good as a state management concept, however, when we try to realize it in real and complex projects, we encounter numerous problems and headaches which is why many developers refuse to use Redux.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://redux-toolkit.js.org/" rel="noopener noreferrer"&gt;ReduxToolkit&lt;/a&gt; tried to solve these problems but with no result.&lt;/p&gt;

&lt;p&gt;I created the &lt;a href="https://redux-cool.js.org" rel="noopener noreferrer"&gt;Redux Cool&lt;/a&gt; to solve all of these problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problems
&lt;/h2&gt;

&lt;p&gt;Below are the main problems which we usually face when we use &lt;strong&gt;Redux&lt;/strong&gt; in complex projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Problem 1: Confusion and Boredom
&lt;/h3&gt;

&lt;p&gt;In many projects that have various features, there are many cases when it is required to change the state during some actions. We have to create a new &lt;em&gt;action type&lt;/em&gt; every single time, to add an &lt;em&gt;action handler&lt;/em&gt; for that in reducer, every time we have to &lt;em&gt;import&lt;/em&gt; the appropriate &lt;em&gt;action creator&lt;/em&gt;, create action and dispatch it. This is quite a boring process. Besides, we have many action creators and action handlers, which are just written one under another and not grouped in logical and visual form.&lt;/p&gt;

&lt;h5&gt;
  
  
  Solution:
&lt;/h5&gt;

&lt;p&gt;In &lt;strong&gt;Redux Cool&lt;/strong&gt;, the reducers are created with the help of a &lt;strong&gt;reducer tree&lt;/strong&gt; - the &lt;strong&gt;reducer tree&lt;/strong&gt; is a nested javascript object in which &lt;strong&gt;action-handler&lt;/strong&gt; functions are defined. Each &lt;strong&gt;action-handler&lt;/strong&gt; has its logical place in the &lt;strong&gt;reducer tree&lt;/strong&gt;. The hierarchical order of &lt;strong&gt;action-handlers&lt;/strong&gt; enables us to define reducer-logic in a grouped and visual form.&lt;/p&gt;

&lt;p&gt;Besides, in &lt;strong&gt;Redux Cool&lt;/strong&gt;, we don't have a separate &lt;strong&gt;action creator&lt;/strong&gt; function for each action, instead, we have one &lt;code&gt;actionsCreator&lt;/code&gt; action producer with which we can create any action object in dynamic and inline ways.&lt;/p&gt;

&lt;p&gt;See details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://redux-cool.js.org/docs/concepts/reducer-tree" rel="noopener noreferrer"&gt;Reducer Tree&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://redux-cool.js.org/docs/concepts/reducers-creator" rel="noopener noreferrer"&gt;Reducers Creator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://redux-cool.js.org/docs/concepts/actions-creator" rel="noopener noreferrer"&gt;Actions Creator&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Problem 2: Define a Single Action In Multiple Reducers
&lt;/h3&gt;

&lt;p&gt;In complex projects, we are usually splitting our reducer functions into separate reducer functions, each managing independent parts of the state. Then, using the &lt;strong&gt;combineReducers&lt;/strong&gt; function of Redux, we are combining it creating one general reducer function. Very often, there is a need to have specific types of actions, which we would like to apply simultaneously to all reducers or to specific reducers. For example, when we have &lt;strong&gt;LOGOUT&lt;/strong&gt; action and during that action, we want to erase all the account-specific data that exists in our Redux state.&lt;/p&gt;

&lt;h5&gt;
  
  
  Solution:
&lt;/h5&gt;

&lt;p&gt;The actions have &lt;strong&gt;Global&lt;/strong&gt; and &lt;strong&gt;Local&lt;/strong&gt; contexts in &lt;strong&gt;Redux Cool&lt;/strong&gt;. The actions with Global context can be applied to various Reducers.&lt;/p&gt;

&lt;p&gt;See details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://redux-cool.js.org/docs/concepts/global-and-local-actions" rel="noopener noreferrer"&gt;Global And Local Actions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Problem 3: Actions With Callback capability
&lt;/h3&gt;

&lt;p&gt;Usually, when we are using Redux Middlewares for side effects(e.g. redux-saga), there is a need to have actions with &lt;strong&gt;Callback capability&lt;/strong&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  Solution:
&lt;/h5&gt;

&lt;p&gt;In &lt;strong&gt;Redux Cool&lt;/strong&gt;, all the actions have Callback capability - by default, it is an identity function(x =&amp;gt; x) but we can pass any callback function during the creation of action.&lt;/p&gt;

&lt;p&gt;See details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://redux-cool.js.org/docs/concepts/actions-creator" rel="noopener noreferrer"&gt;Actions Creator&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>redux</category>
      <category>react</category>
      <category>javascript</category>
      <category>news</category>
    </item>
  </channel>
</rss>
