Created
March 27, 2018 04:41
-
-
Save whs/527639c9da0a12f3e37e307a7f77b116 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import routerResolve from 'router5/transition/resolve'; | |
| import { withStore } from './middleware'; | |
| export function rehydrateState(router, state) { | |
| const middlewares = [withStore].map(item => item(router, router.getDependencies())); | |
| return new Promise((resolve, reject) => { | |
| routerResolve( | |
| middlewares, | |
| { | |
| isCancelled: () => false, | |
| toState: state, | |
| fromState: null, | |
| }, | |
| (err, state) => { | |
| if (!err) { | |
| resolve(state); | |
| } else { | |
| reject(err); | |
| } | |
| }, | |
| ); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment