我正在尝试使用Dispatcher.waitFor
但是当我在另一个商店需要一个商店时,它不起作用。
因此,当我发送INIT
事件时,StoreA
正在正确处理它,但StoreB
甚至没有显示调试消息。
var Constants = require('../constants/Constants')
var Dispatcher = require('../dispatcher/Dispatcher')
StoreA.dispatchToken = Dispatcher.register(function (action) {
switch (action.type) {
case ActionTypes.INIT:
// ...
// ...
// ...
StoreA.emitChange()
break
}
}
var ActionTypes = require('../constants/Constants').ActionTypes
var Dispatcher = require('../dispatcher/Dispatcher')
var StoreA = require('./StoreA')
StoreB.dispatchToken = Dispatcher.register(function (action) {
switch (action.type) {
case ActionTypes.INIT:
console.log('Wait for SectionStore')
Dispatcher.waitFor([StoreA.dispatchToken])
console.log('SectionStore Updated')
// ...
// ...
// ...
StoreB.emitChange()
break
}
}
有什么想法吗?
答案 0 :(得分:0)
乍一看,看起来StoreA缺失了:
var ActionTypes = require('../constants/Constants').ActionTypes
此外,您是否在开发者控制台中看到任何错误日志?