Created
January 31, 2015 23:55
-
-
Save kevinold/36734d69cc9ed208f39a to your computer and use it in GitHub Desktop.
Immutable Flux Store example from Lee Byron (@leeb) from his React.js Conf 2015 talk
This file contains hidden or 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
var Immutable = require('immutable'); | |
var todos = OrderedMap(); | |
var TodoStore = createStore({ | |
getAll() { return todos; } | |
}); | |
Dispatcher.register(function(action) { | |
if (action.actionType === "create") { | |
var id = createGUID(); | |
todos = todos.set(id, Map({ | |
id: id, | |
complete: false, | |
text: action.text.trim(); | |
})); | |
TodoStore.emitChange(); | |
} | |
}); | |
var TodoApp = React.createClass({ ...PureRenderMixin... }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I suppose you wanted to write (?)