// 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
Author
rpominov
commented
Dec 21, 2015
Possible parts
- Matcher: https://github.com/troch/path-parser + ?
- History API: https://github.com/rackt/history
<Link>
: ?- Scroll: https://github.com/rackt/scroll-behavior ?
- Glue: https://github.com/rpominov/basic-streams ?
- Render nested react components: do we even need nested?
- Data loading: out of scope?
source → flatMapLatest → flatMapLatest → flatMapLatest → handler
Event = Normal | Error | Redirect | End
fmlNormal, fmlError, fmlRedirect, fmlEnd (?)
- on server source emits a
Normal
and anEnd
, then we wait forEnd
on 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