Rx pushing data through React-Router
See original GitHub issueI have a react App with the data flow being driven by RxJS -> here
Short of it is I subscribe to my data store which I then pump through via the props:
Model.subject.subscribe((appState) => {
React.render(
<App {...appState}/>,
document.getElementById('app')
);
});
Now is there a way I can merge the above subscription into the Router.run…?
Router.run(routes, function (Handler) {
React.render(
<Handler />,
document.getElementById('app')
);
});
I’ve tried the bellow the router still works but the appState isn’t been passed through!!
Model.subject.subscribe((appState) => {
Router.run(routes, function (Handler) {
React.render(
<Handler {...appState}/>,
document.getElementById('app')
);
});
});
Any pointers would be superb thanks 😃
Issue Analytics
- State:
- Created 8 years ago
- Comments:8
Top Results From Across the Web
Rx pushing data through React-Router · Issue #1230 - GitHub
Short of it is I subscribe to my data store which I then pump through via the props: Model.subject.subscribe((appState) => { React.render( <App ......
Read more >React router, pass data when navigating programmatically?
Is there a way to send params (object) along when navigating? There are other options I can think of, but wonder if passing...
Read more >How to pass additional data while redirecting to a route in React
In this article, we will see how we can pass extra data while redirecting to a different route. So let's get started. Using...
Read more >RxJS with React Hooks for state management - LogRocket Blog
Reactive programming is an event-based paradigm that allows us to run asynchronous sequences of events as soon as data is pushed to a...
Read more >Chapter 12. React on the server and integrating React Router
Today you'll find that many apps (like yours) use a robust client-side application to manage the UI and a remote (usually REST) API...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
What you want is a for an observer to be notified when both Router.run and Model.subject publish new values.
This calls for… combineLatest!
First, make Router.run into an observable
Now sprinkle in a dash of combineLatest!
Bam! Rx-ified Router Soup!
Hope that answers your question.
P.S. Adds some spice by introducing flatMap and Rx-ifying render ala Thundercats.js (disclaimer: I am the author of Thundercats)
so solution sat up in
<RouteHandler {...this.props} />
so you can pass your state into the handler then you need to call it’s props to pass to the rest of the app there.