Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
pass state into updateState as 2nd parameter
Browse files Browse the repository at this point in the history
prepare 0.12.0
  • Loading branch information
cellog committed Aug 1, 2017
1 parent 6567fe0 commit d39a4ec
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/md/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ const albumRouteMapping = {
}),
updateState: {
id: id => actions.selectAlbum(id),
track: track => actions.playTrack(track)
track: (track, state) => state.id && actions.playTrack(track)
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ion-router",
"version": "0.11.3",
"version": "0.12.0",
"description": "elegant powerful routing based on the simplicity of storing url as state",
"main": "lib/index.js",
"homepage": "https://cellog.github.io/ion-router",
Expand Down
3 changes: 2 additions & 1 deletion src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export function getStateUpdates(s, newState) {
const oldState = s.state
const changes = changed(oldState, newState)
const update = s.updateState
return changes.map(key => (update[key] ? update[key](newState[key]) : false)).filter(t => t)
return changes.map(key => (update[key] ? update[key](newState[key], newState) : false))
.filter(t => t)
}

export function updateState(s, params, state) {
Expand Down
4 changes: 2 additions & 2 deletions test/helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@ describe('helper functions', () => {
c: 3,
},
updateState: {
a: a => ({ type: 'a', a }),
a: (a, s) => ({ type: 'a', a, b: s.b }),
b: b => ({ type: 'b', b }),
}
}, {
a: 2,
b: 2,
c: 5,
})).eqls([
{ type: 'a', a: 2 },
{ type: 'a', a: 2, b: 2 },
])
})
it('exitRoute', () => {
Expand Down

0 comments on commit d39a4ec

Please sign in to comment.