[Question] How would you extract a part of a large app and reuse it in another app?
For example, a complex multi-step wizard interconnected with other app components. I understand this is a very general question without context. I am looking into different Flux implementations (Facebook's, Nuclear.js, RiotControl) and trying to understand which is more suitable for an existing large app to migrate to and as a result have more benefits than issues. It would be great to hear from the community if someone has got this experience. Thanks in advance!
The stores should be largely reusable. They are very decoupled from the rest of the application, if you have created them correctly. However, dependencies between stores can sometimes make this more difficult. To move a fully decoupled store from one application to another, you would simply need to be using the same action types in both applications.
Thanks, the case you described is quite obvious.
But the complete components rarely consist of a single store. They at least have a set of views, which in turn have a set of styles and other resources. They could also have dependencies on other stores, HTTP APIs etc.
What could be the options to reuse such components?
You can get a lot more reuse out of individual, low-level React components if you pass methods into them as props to define their behavior. This lets you use them in whatever situation you want.
When creating a Flux application that needs to be able to be used multiple times on the page, I find that either need to pass around a reference to the Dispatcher and move to store instances, or I need to pass around an appID for each instance of the app and stick with singleton stores.
So you want to say there is no arrchitecture pattern how to develop Flux apps to make their parts that make a complete component (N stores + M views
- dispatcher + actions + etc) reusable in several apps, am I right?
Please could you also describe passing a dispatcher and moving to store instances in more detail?
Thanks!
Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.