Skip to content

Instantly share code, notes, and snippets.

@goatslacker
Created March 27, 2015 18:51
Show Gist options
  • Save goatslacker/1ddae9c27a822ccdfdd4 to your computer and use it in GitHub Desktop.
Save goatslacker/1ddae9c27a822ccdfdd4 to your computer and use it in GitHub Desktop.
const Alt = require('./')
const Immutable = require('immutable')
const ImmutableUtil = require('./utils/ImmutableUtil')
const alt = new Alt()
const actions = alt.generateActions('fire')
const assign = require('object-assign')
const store = alt.createStore({
displayName: 'ImmutableStore',
state: Immutable.Map({}),
bindListeners: {
handleFoo: actions.fire
},
lifecycle: {
init: function () {
console.log('This console log should fire')
}
},
handleFoo: function (x) {
this.setState(this.state.set('foo', x))
}
})
actions.fire('hello')
console.log(store.getState().toJS().foo === 'hello')
console.log(JSON.parse(alt.takeSnapshot()).ImmutableStore.foo === 'hello')
var wtf = Immutable.Map({})
console.log(wtf.toJS().foo === undefined)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment