-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
From Flux to Relay - listening to changes deep within the Relay Store. #660
Comments
Found this on StackOverflow http://stackoverflow.com/questions/33616360/how-to-fire-flux-actions-for-relaymutations/34113583#34113583 But it's only ever going to be optimistic but you can't undo a toast or a beep, so I need the result of the fat query before I dispatch actions my arbitrary components are listening to. |
listens intently |
Relay Containers subscribe to the store for updates to their fragment data. Rather than directly update components, mutations cause data to be updated in the store, which then notifies any affected containers.
It's a bit unclear how these components decide to when to update. Do they respond to arbitrary events? In which case, the linked StackOverflow question provides a mechanism for notifying your application when a mutation completes. Alternately, do they respond to data? In this case, why not make these Relay containers and fetch the data they need? |
@josephsavona Thanks for the answers. I think #114 will address the use-cases I was getting at! |
Say I perform a "Like" mutation and my fat query updates a number of child components down the tree. One of those components is a "Counter" component which whenever updated, must trigger a number of superficial UI updates, e.g. show a toast / notification and perhaps trigger a beep sound.
Say both the
<toast>
and<beep>
are arbitrary components i.e. NOT BACKED BY DATA but do need to accept props and render in response to arbitrary events. In a typical Flux case, I could just set the component state to LikeStore.getState() - how do I go about this in my Relay application?If there isn't a way for arbitrary components to subscribe to mutations (better yet, results of the fat query) then most applications WILL need to use Flux along side Relay. This would mean I end up tracking two branches of my application state one for arbitrary components outside of Relay and the other for components with data managed by Relay - this can get messy!
The text was updated successfully, but these errors were encountered: