1

我正在使用 React.js 和 Reflux 开发 Chrome 扩展程序。现在,当使用一个回调更新商店时,我需要通知扩展的所有部分有关更改的信息。

就像是:

function(newStore){
  chrome.runtime.sendMessage({action: 'updateStore', store: newStore});
}

Reflux 中添加此类回调的意义在哪里?

4

1 回答 1

3

我还没有使用 Reflux 构建 chrome 扩展,但通常模式是调用:

store.listen(function(data) {
    // data is whatever your store invoked by saying this.trigger(...)
});

每当您的商店调用使用新数据触发时,都会调用回调函数。

于 2015-08-19T00:53:21.233 回答