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 ```javascript
var Dispatcher = require('./Dispatcher'); var Dispatcher = require('./Dispatcher');
var merge = require('react/lib/merge'); var AppDispatcher = new Dispatcher();
var AppDispatcher = merge(Dispatcher.prototype, {
/** /**
* A bridge function between the views and the dispatcher, marking the action * A bridge function between the views and the dispatcher, marking the action
* as a view action. Another variant here could be handleServerAction. * as a view action. Another variant here could be handleServerAction.
* @param {object} action The data coming from the view. * @param {object} action The data coming from the view.
*/ */
handleViewAction: function(action) { AppDispatcher.handleViewAction = function(action) {
this.dispatch({ this.dispatch({
source: 'VIEW_ACTION', source: 'VIEW_ACTION',
action: action action: action
}); });
} };
});
module.exports = AppDispatcher; module.exports = AppDispatcher;
``` ```

Loading…
Cancel
Save