What about indirect actions?
- I have store S1 which listens to actions A1, A2 and A3.
- Then I have store S2 which only change when the S1 store changes.
- With flux architecture I have to make S2 also listen on actions A1, A2 and A3?
This is not DRY and can lead to many bugs.
What is your opinion? How to solve this?
I'd venture to say that S1 and S2 should probably be the same store. Why aren't they?
@fisherwebdev Because they are not sharing the same data. For example S1 is a jobStore and S2 is an achievementStore. The achivements are only increased when the jobs are done.
Why not manage both jobs and achievements in one store? If you really want to separate the code for readability/maintainability, then yes, you want to have those actions as cases in the AchievementStore's switch statement, waitFor the JobStore, and then retrieve the updated data from the JobStore. But if you can, it really sounds like they should be the same store. waitFor is really a last resort for managing complexity, and not at all the ideal in a well-designed system. Sometimes, it's unavoidable. But in your situation, I would seriously consider merging the two stores. Please remember that stores are not ORM-style models, and they are not Backbone collections. They manage a "domain" of logic and data. It sounds to me like jobs and achievements might actually be within the same domain.
But I also have other stores which will change the archievement store. I will have too many stores joied in the same store. Then is a mess again.
On Thursday, October 9, 2014, Bill Fisher [email protected] wrote:
Why not manage both jobs and achievements in one store? If you really want to separate the code for readability/maintainability, then yes, you want to have those actions as cases in the AchievementStore's switch statement, waitFor the JobStore, and then retrieve the updated data from the JobStore. But if you can, it really sounds like they should be the same store. waitFor is really a last resort for managing complexity, and not at all the ideal in a well-designed system. Sometimes, it's unavoidable. But in your situation, I would seriously consider merging the two stores. Please remember that stores are not ORM-style models, and they are not Backbone collections. They manage a "domain" of logic and data. It sounds to me like jobs and achievements might actually be within the same domain.
— Reply to this email directly or view it on GitHub https://github.com/facebook/flux/issues/75#issuecomment-58539059.
Best regards, Melhores cumprimentos,
Blog : ProJavaScript https://WebDesignPorto.com?utm_source=email-footer-text&utm_medium=email-footer-text&utm_campaign=email-footer-text Twitter : @ProJavaScript https://twitter.com/ProJavaScript Google+ : ProJavaScript+ https://plus.google.com/104273320601694264357/posts
https://WebDesignPorto.com?utm_source=email-footer-logo&utm_medium=email-footer-logo&utm_campaign=email-footer-logo