[Flux] 2. Overview and Dispatchers

Flux has four major components: Stores, Dispatchers, Views, and Actions. These components interact less like a typical MVC and more like an Event Bus. 

 

src/js/dispatchers/app-dispatcher.js

var Dispatcher = require('flux').Dispatcher,
    assign = require('react/lib/Object.assign');

var AppDispatcher = assign(new Dispatcher(), {
    handleViewAction: function (action) {
        this.dispatch({
            source: 'VIEW_ACTION',
            action: action
        });
    }
});

module.exports = AppDispatcher;

 

posted @ 2015-09-04 16:31  Zhentiw  阅读(189)  评论(0编辑  收藏  举报