Reputation: 11
Using the new flux/utils, I have a Store with a timer that needs to be either running or not running depending on the current state of the store. When the timer ends I need to change the state in the store and emit a change.
The problem is that with the new flux utils you can't emit an event outside of the dispatch cycle. How would you handle this?
I don't think doing something like moving the timer into a component is a good idea, similarly having the timer at the api/dispatcher level probably isn't a good idea, since we need to know the state of the store to possibly cancel the timer/etc...
Upvotes: 0
Views: 84
Reputation: 696
This is an example of why I find Flux quite difficult to work with sometimes.
A timer is by nature a dynamic element, and in your case it is supposed to change something, that is, trigger an action. This is why I think it would be better in a view.
This way:
Hope this will help you
Upvotes: 0