Skip to content

Instantly share code, notes, and snippets.

@goatslacker
Created March 27, 2015 19:06
Show Gist options
  • Save goatslacker/6837de6e697909287ffe to your computer and use it in GitHub Desktop.
Save goatslacker/6837de6e697909287ffe 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(ImmutableUtil.makeImmutableStore({
// displayName: 'ImmutableStore',
//
// bindListeners: {
// handleFoo: actions.fire
// },
//
// lifecycle: {
// init: function () {
// console.log('This console log should fire')
// }
// },
//
// handleFoo: function (x) {
// this.setState('foo', x)
// }
//}))
const store = alt.createStore(ImmutableUtil.makeImmutableStore(function Foo() {
this.foo = 'bar'
this.handleFoo = function (x) {
this.setState('foo', x)
}
this.bindListeners({
handleFoo: actions.fire
})
}), 'ImmutableStore')
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