Get router history working with flux
This commit is contained in:
@@ -38,8 +38,14 @@ export default Actions({
|
||||
});
|
||||
},
|
||||
|
||||
updateRoute(route) {
|
||||
return { route };
|
||||
},
|
||||
goBack: null
|
||||
// routing
|
||||
goTo: null,
|
||||
goBack: null,
|
||||
updateLocation(location) {
|
||||
return {
|
||||
transform(state) {
|
||||
return { ...state, location };
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
@@ -20,7 +20,12 @@ export default Store({
|
||||
value: initValue
|
||||
},
|
||||
init({ instance: appStore, args: [cat] }) {
|
||||
const { updateRoute, getUser, setTitle } = cat.getActions('appActions');
|
||||
const {
|
||||
updateLocation,
|
||||
getUser,
|
||||
setTitle
|
||||
} = cat.getActions('appActions');
|
||||
|
||||
const register = createRegistrar(appStore);
|
||||
const {
|
||||
toggleQuestions,
|
||||
@@ -33,7 +38,17 @@ export default Store({
|
||||
} = cat.getActions('hikesActions');
|
||||
|
||||
// app
|
||||
register(setter(fromMany(getUser, setTitle, updateRoute)));
|
||||
register(
|
||||
fromMany(
|
||||
setter(
|
||||
fromMany(
|
||||
getUser,
|
||||
setTitle
|
||||
)
|
||||
),
|
||||
updateLocation
|
||||
)
|
||||
);
|
||||
|
||||
// hikes
|
||||
register(
|
||||
|
@@ -218,9 +218,12 @@ export default Actions({
|
||||
const currentHike = findNextHike(hikes, id);
|
||||
|
||||
// go to next route
|
||||
state.route = currentHike && currentHike.dashedName ?
|
||||
`/hikes/${ currentHike.dashedName }` :
|
||||
'/hikes';
|
||||
state.location = {
|
||||
action: 'PUSH',
|
||||
pathname: currentHike && currentHike.dashedName ?
|
||||
`/hikes/${ currentHike.dashedName }` :
|
||||
'/hikes'
|
||||
};
|
||||
|
||||
const hikesApp = {
|
||||
...state.hikesApp,
|
||||
|
Reference in New Issue
Block a user