

Reactjs/Flux: Where to put database api logic? Store or actions? - meandmax

https:&#x2F;&#x2F;github.com&#x2F;meandmax&#x2F;react-flux-dashboard<p>Where would you implement the api call to persist data to the key-value store (firebase).<p>2 options:<p>1. actions&#x2F;counter-actions.js<p><pre><code>    incrementCounter: (id, count) =&gt; {
        let incrementedCount = count + 1;

        counterWebApiUtils.updateCounter(id, incrementedCount).on(&#x27;value&#x27;, (data) =&gt; {
            Dispatcher.dispatch({
                actionType: counterConstants.INCREMENT_COUNTER,
                count: data.val(),
                id
            });
        });
    },
</code></pre>
2. stores&#x2F;counter-store.js (like it is right now)<p><pre><code>    counterWebApiUtils.updateCounter(payload.id, payload.count).on(&#x27;value&#x27;, () =&gt; {
        counters[payload.id].count = payload.count;
        counterStore.emitChange();
    });</code></pre>
======
zubairq
In my Clojurescript React based framework I put it directly in the UI
component:

    
    
        (defn-ui-component  my-todo-app   [app] {}
    
            (select id, item from todo_items
            {}
            (container
                (inline "10%" (str (<-- :id)))  (inline "80%" (str (<-- :item))))))
    

:see here for more details:

[https://github.com/zubairq/coils](https://github.com/zubairq/coils)

