Skip to content

Instantly share code, notes, and snippets.

@flarnie
Created December 9, 2014 00:40
Show Gist options
  • Save flarnie/f548a6bca509194618eb to your computer and use it in GitHub Desktop.
Save flarnie/f548a6bca509194618eb to your computer and use it in GitHub Desktop.
Flux TodoApp Sample 1
// Loading the initial data into the application:
// ...
/**
* Retrieve the current TODO data from the TodoStore
*/
function getTodoState() {
return {
allTodos: TodoStore.getAll(),
areAllComplete: TodoStore.areAllComplete()
};
}
var TodoApp = React.createClass({
getInitialState: function() {
return getTodoState();
},
// ...
@christiantakle
Copy link

Suggestion, change

getInitialState: function() {
  return getTodoState();
},

to

getInitialState: getTodoState,

Thinking about functions as values can help cleaning up a lot of Javascript code.

@fdelacruz
Copy link

I love this suggestion. Thanks @christiantakle!!

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