Skip to content

Instantly share code, notes, and snippets.

@mushfiqweb
Created April 24, 2017 14:28
Show Gist options
  • Save mushfiqweb/6022c71826983253e45e74bc8e69b3fc to your computer and use it in GitHub Desktop.
Save mushfiqweb/6022c71826983253e45e74bc8e69b3fc to your computer and use it in GitHub Desktop.
var state = freezer.get();
// this will replace app state for a new one
state.todos.push({
model: {id: 1, title: 'Do this.', completed: false},
ui: {status: 'ready', input: 'Do this.'}
});
// state variable is still unchanged,
// it is immutable
console.log( state.todos ); // []
// but the state has changed
state === freezer.get(); // false
// our data is in the new state
console.log( freezer.get().todos.length ); // 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment