Fluxible Context 方法挂起

Fluxible Context methods hang

我遇到了 Fluxible Action 上下文中的方法似乎挂起的情况。我认为我的麻烦源于我正在用 ES5 编写的事实,而且我不得不对 Fluxible 主页上的 ES6 示例如何翻译做出最好的猜测 (link and link)。

无论如何,这里有一些相关代码(大大简化以尝试强调我认为可能重要的部分):

Store.js

var BaseStore = require('fluxible/addons/BaseStore');
var assign = require('object-assign');

var Store = assign({}, BaseStore.prototype, {
    handleAction: function(data) {
       console.log('Action Done');
       this.emitChange();
    }
    ... (other methods) ...
}

Store.storeName = 'Store';
Store.handlers = { 'ACTION_DONE': 'handleAction' };

module.exports = Store;

Actions.js

var Promise = require('promise');
var Store = require('./Store');

var Actions = {
   action1: function(context, payload) {
       return new Promise(function(resolve, reject) {
           console.log('Action 1');
           context.dispatch('ACTION_DONE', {});
           resolve(true);
       });
   },

   action2: function(context, payload) {
       return new Promise(function(resolve, reject) {
           // Try to fetch a value from the store and display it
           var store = context.getStore(Store.constructor);
           console.log(store.getValue());
           context.dispatch('ACTION_DONE', {});
           resolve(true);
       });
   }
}

module.exports = Actions;

并且我在以下几行中使用了整个设置

var Promise = require('promise');
var Fluxible = require('fluxible');
var Store = require('./Store');
var Actions = require('./Actions');

var app = new Fluxible();
app.registerStore(Store.constructor);

var context = app.createContext();
var action1 = context.executeAction(Actions.action1, {});
var action2 = context.executeAction(Actions.action2, {});

Promise.all([action1, action2]).then(function(val) { console.log('done'); });

我在使用 print 语句进行调试时发现,执行卡在 Actions.action1 中的 context.dispatch('ACTION_DONE', {});Actions.action2 中的 var store = context.getStore(Store.constructor); 处。这让我对我对示例的 ES5 翻译感到疑惑——尤其是我对 Store.js.

的实现

如有任何帮助,我们将不胜感激。如果我可以提供更多信息,请告诉我。

原来 fluxible/addons 中的方法 createStore 可以解决我的问题 - 将 assign({}, BaseStore.prototype, { ... }) 更改为 createStore({ ... })

我不完全明白我现在做的和我以前做的有什么区别;所以随时回应解释。现在,我的问题已经解决了。