Last active
June 22, 2017 18:14
-
-
Save gearmobile/e34332360d4215be4f681e5988dca59a to your computer and use it in GitHub Desktop.
Можно ли вынести часть кода в отдельную функцию в mutations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const reverseUsersStatus = (users, { id }) => { | |
users.find(el => { | |
if (el.id === id) { | |
el.status = !el.status | |
} | |
}) | |
} | |
const mutations = { | |
'SET_REGISTRATION' (state, payload) { | |
reverseUsersStatus(state.users, payload) | |
state.registration.push(payload) | |
}, | |
'UNSET_REGISTRATION' (state, payload) { | |
reverseUsersStatus(state.users, payload) | |
const index = state.registration.indexOf(payload) | |
state.registration.splice(index, 1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment