What about complex alerts (like a popup)? #78
Comments
A lot of this seems very specific to your application, and it's difficult to get enough context from what you have written here. Perhaps more code would help the community here understand your issue? But on a side note, this concerns me: alertStore.add({contents: new UnlockJob({...})}) That looks an awful lot like a setter on your store, and a store should not have any setter methods. The only way data should be getting into the store is though the callback it registers with the dispatcher. |
Imagine a popup, where would you store in your app? |
I would render a PopupControllerView at the bottom of the body, in it's own React root, which would be listening to stores. It might have number of child popups, or I might create logic to dynamically create those children. I might maintain a PopupStore, which would have currentPopupID value, which could be null. Down in my list of popup components, they would all receive currentPopupID as a prop, and if their popupID matched, they would get displayed. Or I would simply let the values in the other stores drive what popup to render more directly, perhaps with some logic in PopupControllerView determining if a popup should be displayed, or which one. Basically this is all just Flux + React -- nothing special going on, other than creating a separate root for it, and I'm not even sure that's necessary. The generic Popup React component could be made to simply take props and let the store or controller-view above it determine those props. You could then use that generic component to compose various different popups. |
I'm still trying to figure out how to setup alerts like a popups.
I've tried both approaches and nothing seems correct.
An alert store?
If the contents of the alert has more logic, is managed by whom? The alert can't manage that.
Here is how is done:
alertStore.add({contents: new UnlockJob({...})})
alertStore.getAll().map(function(alert){return alert})
Or should the domain store keep some variable to let me know that needs to open the store?
How do I open the alert in the first place? I do:
myStore.unlockingJob ? new UnlockJob({...}) : null
(the UnlockJob is the alert view) in my root component. But then I can't manage any alerts properly.The text was updated successfully, but these errors were encountered: