Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

What about complex alerts (like a popup)? #78

Closed
totty90 opened this issue Oct 11, 2014 · 3 comments
Closed

What about complex alerts (like a popup)? #78

totty90 opened this issue Oct 11, 2014 · 3 comments

Comments

@totty90
Copy link

totty90 commented Oct 11, 2014

I'm still trying to figure out how to setup alerts like a popups.

  • Should I have an alert store?
  • Or should the domain store keep some variable to let me know that needs to open the store?

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({...})})
  • In my root 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.

@totty90 totty90 changed the title What about complex alerts? What about complex alerts (like a popup)? Oct 11, 2014
@fisherwebdev
Copy link
Contributor

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.

@totty90
Copy link
Author

totty90 commented Oct 25, 2014

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?

Imagine a popup, where would you store in your app?

@fisherwebdev
Copy link
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants