-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a problem triggering actions from a store? #4
Comments
There is no limitation of which I'm aware. That said, it may be desirable to keep actions out of stores to mitigate hard-to-understand cascading effects. |
I ran into a similar use case when I was experimenting with different pieces of code. A store could technically use I found two Solutions to my problem: You can do something like: Use two separate actions that are only triggered in my stores show and index methods and have my components listening to these actions, instead of stores. Thus changing the reflux lifecyle to more of a.... ......... [Action] -> ........ [Store] -> ....... [Action] -> ........ [View Component] -> (start over) So in your Component you have...
QUESTIONS:
Thanks! |
The wiring between the store and the view is typically the hard part! If you want to use actions for that, I don't foresee any immediate technical problems, but it does bastardize the idea of a flux action a bit, so it might be confusing to those who are new to your codebase. Often one would If you need to broadcast more granular changes, I would suggest creating/finding some protocol that can describe those changes to the view and What view layer are you using? Is it react? |
@devinivy Thanks for the response. Digging a little deeper I see why the more granular actions are not needed using react, even in more complex situations. Making a couple adjustments to how the stores are setup and utilized makes the reflux lifecycle become much more beneficial. |
I look at actions/listeners as a publish/subscribe pattern and use actions wherever and in series if called for. Some flux implementations seem to have a problem calling an action from within another action. I have not had any issues doing Action -> Store -> Api.get -> Api.got -> Action -> Store -> Action -> Api.get -> Api.got -> Store -> Store.trigger. Do you see any problem using this pattern in reflux?
The text was updated successfully, but these errors were encountered: