flux multiple store instances

*爱你&永不变心* 提交于 2019-11-30 06:57:28

The Flux way is to create singleton stores. They are not models as we are used to thinking about models in an ORM-style MVC pattern. Stores are instantiated only at the moment of the application's initialization. They manage a "domain" of logic and data.

These singleton stores register a callback with the dispatcher. The callback is the only way data gets into the stores. Stores also provide getter methods as a public API -- the only way data gets out. There are no setters. Stores are a universe of their own, completely in control of their data and behavior.

In your case, it sounds like the logical domains are Athlete and Workout, so I would create an AthleteStore and a WorkoutStore, and maintain collections of those two things within their respective stores. I'd imagine you'll have getters like getWorkoutsByAthleteID(), for example.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!