Skip to content

Instantly share code, notes, and snippets.

@whs
Created March 27, 2018 04:41
Show Gist options
  • Select an option

  • Save whs/527639c9da0a12f3e37e307a7f77b116 to your computer and use it in GitHub Desktop.

Select an option

Save whs/527639c9da0a12f3e37e307a7f77b116 to your computer and use it in GitHub Desktop.
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