Browse Source

Update flux-todo-list.md

You have to instantiate a Dispatcher to use it, not just grab the prototype or it will fail when trying to grab instance properties like: this.$Dispatcher._callbacks.
main
Christian Alfoni 10 years ago
parent
commit
42a2b28a49
  1. 20
      docs/flux-todo-list.md

20
docs/flux-todo-list.md

@ -147,23 +147,19 @@ Now we are all set to create a dispatcher that is more specific to our app, whic
```javascript
var Dispatcher = require('./Dispatcher');
var merge = require('react/lib/merge');
var AppDispatcher = merge(Dispatcher.prototype, {
var AppDispatcher = new Dispatcher();
/**
/**
* A bridge function between the views and the dispatcher, marking the action
* as a view action. Another variant here could be handleServerAction.
* @param {object} action The data coming from the view.
*/
handleViewAction: function(action) {
this.dispatch({
source: 'VIEW_ACTION',
action: action
});
}
});
AppDispatcher.handleViewAction = function(action) {
this.dispatch({
source: 'VIEW_ACTION',
action: action
});
};
module.exports = AppDispatcher;
```

Loading…
Cancel
Save