Skip to content

Instantly share code, notes, and snippets.

@goatslacker
Last active August 29, 2015 14:16
Show Gist options
  • Save goatslacker/0f709f4436ed4890945d to your computer and use it in GitHub Desktop.
Save goatslacker/0f709f4436ed4890945d to your computer and use it in GitHub Desktop.
var Alt = require('./')
var alt = new Alt()
var actions = alt.generateActions('fire')
function MyStore() {
return {
displayName: 'MyStore',
state: {
data: 1
},
publicMethods: {
getData: function () {
return this.getState().data
}
},
lifecycle: {
init: function () {
console.log('i was initialized')
}
},
bindListeners: {
handleFire: actions.FIRE
},
handleFire: function (data) {
// console.log('@', this)
this.state.data = data
}
}
}
var store = alt.createStore(MyStore())
//console.log('@', store.getEventEmitter, store.getState)
console.log(1, store.getData())
actions.fire(2)
console.log(2, store.getState())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment