Skip to content

Instantly share code, notes, and snippets.

@goatslacker
Last active August 29, 2015 14:17
Show Gist options
  • Save goatslacker/f031f4684205be40cea7 to your computer and use it in GitHub Desktop.
Save goatslacker/f031f4684205be40cea7 to your computer and use it in GitHub Desktop.
const Immutable = require('immutable');
const Alt = require('alt');
const alt = new Alt();
const actions = alt.generateActions('fire');
const store = alt.createStore({
displayName: 'ImmutableStore',
bindListeners: {
onSomething: actions.fire
},
state: Immutable.Map({}),
onSomething(x) {
// or this? this.setImmutableState('foo', x);
this.setState(this.state.set('foo', x));
}
});
store.getState().foo // undefined
actions.fire('hello world')
store.getState().foo // hello world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment