我已经使用 Fluxxor 设置了一个 React 应用程序,我正在尝试使用一个 Controller View 来获取多个存储和操作,类似于此 carousel example .
但是,在 Fluxxor 示例中,它使用多个存储,但仅使用一组操作。我想知道如何传递多个 Action 。
var React = require('react/addons'),
Fluxxor = require("fluxxor"),
authorActions = require("../actions/author-actions"),
authorStore = require("../stores/author-store"),
productActions = require("../actions/product-actions"),
productStore = require("../stores/product-store");
var stores = { ProductStore: new productStore(), AuthorStore: new authorStore() };
// how do I combine my actions here?
var flux = new Fluxxor.Flux(stores, actions);
最佳答案
Fluxxor supports adding actions dynamically :
var flux = new Fluxxor.Flux(stores);
flux.addActions(authorActions);
flux.addActions(productActions);
如果命名空间不冲突,您还可以将它们合并在一起,例如 Underscore's extend :
var actions = _.extend({}, authorActions, productActions);
或Object.assign
(或polyfill):
var actions = Object.assign({}, authorActions, productActions);
关于javascript - Fluxxor 将 1 组以上的操作添加到 Flux 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29551775/