Skip to content

Commit

Permalink
Updated example to use new handler arity
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneslumpe committed Oct 18, 2015
1 parent 9fbdb6e commit 73b138d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions example/actions/Items.js
Expand Up @@ -17,7 +17,7 @@ export default {
}
},
meta: {
transition: ({ items: { lastItemId } }, action) => ({
transition: (prevState, { items: { lastItemId } }, action) => ({
path: `/item-details/${lastItemId}`,
})
}
Expand All @@ -31,7 +31,7 @@ export default {
id
},
meta: {
transition: (state, action) => ({
transition: (prevState, nextState, action) => ({
path: '/item-list'
})
}
Expand Down
4 changes: 3 additions & 1 deletion example/actions/Routing.js
Expand Up @@ -9,7 +9,9 @@ export default {
return {
type: ENTITY_NOT_FOUND,
meta: {
transition: (state, action) => ({ path: '/entity-not-found' })
transition: (prevState, nextState, action) => (
{ path: '/entity-not-found' }
)
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions example/actions/Session.js
Expand Up @@ -9,7 +9,7 @@ export default {
return {
type: LOGGED_IN,
meta: {
transition: (state, action) => ({ path: '/logged-in'})
transition: (prevState, nextState, action) => ({ path: '/logged-in'})
}
};
},
Expand All @@ -18,7 +18,7 @@ export default {
return {
type: LOGGED_OUT,
meta: {
transition: (state, action) => ({ path: '/' })
transition: (prevState, nextState, action) => ({ path: '/' })
}
};
}
Expand Down
4 changes: 2 additions & 2 deletions example/index.js
Expand Up @@ -11,11 +11,11 @@ import { TRANSITION_TO_ROOT } from './constants/ActionTypes';

const history = useQueries(createHistory)();

const store = createStore(history, (state, { type }) => {
const store = createStore(history, (prevState, nextState, { type }) => {
if (type === TRANSITION_TO_ROOT) {
// this does not do anything useful right now, but serves
// as an example how a catch-all handler could be used
const { lastItemId } = state.items;
const { items: { lastItemId } } = nextState;
const query = lastItemId ? { lastItemId } : null;
return { path: '/', query };
}
Expand Down

0 comments on commit 73b138d

Please sign in to comment.