N
N
nd0ut2015-05-25 00:56:08
flux
nd0ut, 2015-05-25 00:56:08

Flux: pull an action after another action?

Abstract case:
We have an ItemStore, a checkItem action, and an ItemsView.
The user clicks on an item, checkItem twitches, the store is updated, the view does a re-render. Everything is fine, everyone is happy.
Next, it became necessary to execute an asynchronous request when the user selects an item, and then update another store, for example, LogStore. And such things should be performed through asynchronous actions. That is, we need to pull one action after another. Let's call this action sendLog. Like we send this item to some remote logger, and then we shove the answer into the LogStore (stupid example, well, figs with it).
It would be possible to simply make a request in the checkItem action, but the catch is that this sendLog has nothing to do with all these items at all. And in theory, neither ItemStore, nor checkItem, nor ItemView should know anything about this request, and the request should be made without their participation. It would be possible to pull sendLog in the ListView, but, again, it is neither in the village nor in the city.
You cannot listen to checkItem in the LogStore and pull the sendLog action or send a request from the store. It's not in flux.
It would be possible to listen to checkItem in some separate class and pull sendLog in the handler, but this seems to violate the undirectional data flow, besides, we would rather get `dispatch in the middle of dispatch`.
In general, I can not come to the right decision in any way. Perhaps my mistake is in the task itself.
Case based on a real task. I use flummox.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question