Created
March 27, 2015 20:56
-
-
Save goatslacker/2dceff389071418de68f to your computer and use it in GitHub Desktop.
This file contains 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 ImmutableUtil = require('./utils/ImmutableUtil') | |
const Immutable = require('immutable') | |
const Alt = require('./') | |
const alt = new Alt() | |
const actions = alt.generateActions('fire') | |
//function ImmutableStore() { | |
// this.handleFoo = function (x) { | |
// this.setState('foo', x) | |
// }.bind(this) | |
// | |
// this.bindListeners({ | |
// handleFoo: actions.fire | |
// }) | |
const ImmutableStore = { | |
displayName: 'ImmutableStore', | |
state: { | |
foo: 'hello' | |
}, | |
bindListeners: { | |
handleFoo: actions.fire | |
}, | |
handleFoo: function (x) { | |
this.setState(this.state.set('foo', x)) | |
this.setState('foo', x) | |
} | |
} | |
const store = ImmutableUtil.createStore(alt, ImmutableStore, 'ImmutableStore') | |
console.log(store.getState().toJS().foo, 'foo has not been defined') | |
actions.fire('lol') | |
console.log(store.getState().toJS().foo === 'lol', 'foo has been defined') | |
var newMap = Immutable.Map({}) | |
console.log(newMap.foo, 'references do not leak') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment