Skip to content

Commit

Permalink
move silent flag out of payload (vuejs#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsn authored and yyx990803 committed Aug 15, 2016
1 parent 565ebe6 commit faac7ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class Store {
this.dispatch = function boundDispatch (type, payload) {
return dispatch.call(store, type, payload)
}
this.commit = function boundCommit (type, payload) {
return commit.call(store, type, payload)
this.commit = function boundCommit (type, payload, options) {
return commit.call(store, type, payload, options)
}

// strict mode
Expand All @@ -58,10 +58,11 @@ class Store {
assert(false, `Use store.replaceState() to explicit replace store state.`)
}

commit (type, payload) {
commit (type, payload, options) {
// check object-style commit
let mutation
if (isObject(type) && type.type) {
options = payload
payload = mutation = type
type = type.type
} else {
Expand All @@ -77,7 +78,7 @@ class Store {
handler(payload)
})
})
if (!payload || !payload.silent) {
if (!options || !options.silent) {
this._subscribers.forEach(sub => sub(mutation, this.state))
}
}
Expand Down
6 changes: 4 additions & 2 deletions test/unit/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,10 +623,12 @@ describe('Vuex', () => {
type: TEST,
n: 2
})
store.commit(TEST, { n: 3 }, { silent: true })
store.commit({
type: TEST,
silent: true,
n: 3
n: 4
}, {
silent: true
})
expect(mutations.length).toBe(2)
expect(mutations[0].type).toBe(TEST)
Expand Down

0 comments on commit faac7ca

Please sign in to comment.