Creating a dispatcher
Now let's implement this data flow. We'll start by creating a dispatcher first. Facebook offers us its implementation of a dispatcher that we can reuse. Let's take advantage of this.
- Navigate to the
~/snapterest
directory and run the following command:npm install --save flux
The
flux
module comes with aDispatcher
function that we'll be reusing. - Next, create a new folder called
dispatcher
in our project's~/snapterest/source/dispatcher
directory. Now create theAppDispatcher.js
file in it:var Dispatcher = require('flux').Dispatcher; module.exports = new Dispatcher();
First, we import Dispatcher
provided by Facebook, then create, and export a new instance of it. Now we can use this instance in our application.
Next, we need a ...
Get React.js Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.