Skip to content

Instantly share code, notes, and snippets.

@Sawtaytoes
Last active April 25, 2019 04:39
Show Gist options
  • Save Sawtaytoes/63ed12678d9367e32f46c627d5e712b4 to your computer and use it in GitHub Desktop.
Save Sawtaytoes/63ed12678d9367e32f46c627d5e712b4 to your computer and use it in GitHub Desktop.
var actions = {
UPDATE_IDS: function(action) {
vm.ids = action.ids
},
UPDATE_PRIVILAGES: function(action) {
vm.privileges = action.privileges
},
}
var dispatch = function(
action,
) {
if (!action.type) {
console
.error(
"No type for action",
action,
)
}
if (window.__isDebugging) {
console
.info(
action.type,
action,
)
}
actions[action.type]
&& actions[action.type](action)
return action
}
var vm = this
vm.onClick = function() {
idsService
.get()
.then(function(ids) {
dispatch({
ids: ids,
type: 'UPDATE_IDS',
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment