Skip to content

Instantly share code, notes, and snippets.

@kevinold
Created January 31, 2015 23:55
Show Gist options
  • Save kevinold/36734d69cc9ed208f39a to your computer and use it in GitHub Desktop.
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
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... });
@MandarinConLaBarba
Copy link

I couldn't find a live example of what @leebyron demonstrated during his talk, so I created one:

https://github.com/MandarinConLaBarba/flux-immutable-todomvc

@AoDev
Copy link

AoDev commented Apr 13, 2015

Hi, I suppose you wanted to write (?)

var todos = Immutable.OrderedMap();
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment