@@ -2,6 +2,7 @@ import { createAction, handleActions } from 'redux-actions-helpers';
22
33// actions
44export const startTransition = createAction ( '@@router/START_TRANSITION' , payload => ( { payload } ) ) ;
5+ export const resolved = createAction ( '@@router/RESOLVED' , payload => ( { payload } ) ) ;
56export const endTransition = createAction ( '@@router/END_TRANSITION' , payload => ( { payload } ) ) ;
67
78// reducer
@@ -12,7 +13,7 @@ const initialState = {
1213 status : null ,
1314 params : null ,
1415 redirect : null ,
15-
16+ isTransition : false
1617} ;
1718export const reducer = handleActions ( {
1819 [ startTransition ] : ( state , { payload } ) => {
@@ -21,6 +22,12 @@ export const reducer = handleActions({
2122 ...payload
2223 }
2324 } ,
25+ [ resolved ] : ( state , { payload } ) => {
26+ return {
27+ ...state ,
28+ ...payload
29+ }
30+ } ,
2431 [ endTransition ] : ( state , { payload } ) => {
2532 return {
2633 ...state ,
@@ -32,9 +39,12 @@ export const reducer = handleActions({
3239// hook
3340export const hookRedux = ( { dispatch } ) => ( {
3441 start : ( { path, location } ) => {
35- dispatch ( startTransition ( { path, location } ) ) ;
42+ dispatch ( startTransition ( { path, location, isTransition : true } ) ) ;
3643 } ,
3744 resolve : ( { route, status, params, redirect } ) => {
3845 dispatch ( endTransition ( { route, status, params, redirect } ) ) ;
46+ } ,
47+ render : ( ) => {
48+ dispatch ( endTransition ( { isTransition : false } ) ) ;
3949 }
4050} ) ;
0 commit comments