<?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: Cosmin Cimpoi</title>
    <description>The latest articles on DEV Community by Cosmin Cimpoi (@ccimpoi).</description>
    <link>https://dev.to/ccimpoi</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%2F905777%2F7a113c4c-978f-4ed5-8fce-67f38e3f6132.png</url>
      <title>DEV Community: Cosmin Cimpoi</title>
      <link>https://dev.to/ccimpoi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ccimpoi"/>
    <language>en</language>
    <item>
      <title>The story of x, my Redux pure JS all killer no filler</title>
      <dc:creator>Cosmin Cimpoi</dc:creator>
      <pubDate>Tue, 09 Aug 2022 09:50:34 +0000</pubDate>
      <link>https://dev.to/ccimpoi/the-story-of-x-my-redux-pure-js-all-killer-no-filler-4je9</link>
      <guid>https://dev.to/ccimpoi/the-story-of-x-my-redux-pure-js-all-killer-no-filler-4je9</guid>
      <description>&lt;p&gt;I am diving into React with Redux.&lt;br&gt;
I always fall into the trap of trying to skip the fundamentals.&lt;br&gt;
I always choose the hard way.&lt;br&gt;
You can never skip the fundamentals.&lt;br&gt;
I do not understand why they put the essentials before the fundamentals but I should have known better.&lt;/p&gt;

&lt;p&gt;Here is the story of x, my Redux pure JS all killer no filler:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
  &amp;lt;hread&amp;gt;
    &amp;lt;script src="https://unpkg.com/redux@latest/dist/redux.min.js"&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;/hread&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;p id="xValueDisplay"&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;input id="xValueInput" /&amp;gt;
    &amp;lt;button id="xValueSetter"&amp;gt;Set&amp;lt;/button&amp;gt;
    &amp;lt;script&amp;gt;
      // the UI
      const xValueDisplayEl = document.getElementById('xValueDisplay');
      const xValueInputEl = document.getElementById('xValueInput');
      const xValueSetterEl = document.getElementById('xValueSetter');

      // the initial state of the reducer
      const appInitialState = {
        x: 'change me'
      }

      // the reducer
      function appReducer(state = appInitialState, action) {
        switch (action.type) {
          case 'x/wasSet':
            return { ...state, x: action.payload};
          default:
            return state;
        }
      }

      // the store
      const appStore = Redux.createStore(appReducer);

      // the UI renderer
      function appRender() {
        const state = appStore.getState();
        xValueDisplayEl.innerHTML = state.x;
        xValueInputEl.value = state.x;
      }
      // first render with the state of the store
      appRender();
      // subscribe the renderer to the store updates
      appStore.subscribe(appRender);

      xValueSetterEl.addEventListener('click', function() {
        // we dispatch the x/wasSet action to change store state
        appStore.dispatch({ type: 'x/wasSet', payload: xValueInputEl.value });
      });
    &amp;lt;/script&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>redux</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
