// trnsitionRequests -> BrowserAPI -> [ resolveRoute -> loadData -> render -> restoreScroll ]
// poor man's strem.flatMapLatest()
router.pipe((payload, next) => {
next(1)
next(2)
return () => {
// cleanup
}
})
createRouter(callback => {
browserHistoryAPI.listen(callback)
})
.pipe(createNestedReactResolver(...))
.pipe(createReactDataLoader(...))
.pipe(createNestedReactRenderer(...))
.pipe(createScrollRestorer(...))
Last active
May 4, 2016 22:34
-
-
Save rpominov/acb11abfb5383be6db70 to your computer and use it in GitHub Desktop.
Router concept
source → flatMapLatest → flatMapLatest → flatMapLatest → handlerEvent = Normal | Error | Redirect | EndfmlNormal, fmlError, fmlRedirect, fmlEnd (?)- on server source emits a
Normaland anEnd, then we wait forEndon other side and use the previousEvent fml(a -> Stream<b,c,d> | Event<b,c,d>)
Event = {type: ... | 'END', payload: any}
Middleware = Event -> Event | Stream<Event> | Array<Event>
{type: 'END'} is special Event, we automatically dispose subscription after it. Other types like 'NORMAL', 'ERROR', 'REDIRECT', etc. are up to user (or maybe not, we might need a convention for example if we provide middlewares out of the box, but only END is special anyway)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Possible parts
<Link>: ?