私はRefluxを使用していますが、通常はajax呼び出しを行った後にトリガーしていますが、うまく機能しています。テスト目的で ajax 呼び出しは必要ありませんでしたが、最小 5 ミリ秒のタイムアウトを指定しない限り、トリガーが機能しないことに気付きました。ここに動作する例と動作しない例があります。
動作しない例:
window.threadStore = Reflux.createStore
init: ->
@state = @getInitialState()
@fetchThreads()
getInitialState: ->
loaded: false
threads: []
fetchThreads: ->
# ajax call for not Testing, and just trigger for Testing
@state.threads = FakeData.threads(20)
@state.loaded = true
@trigger(@state) # This will NOT work!
これはうまくいきます:
window.threadStore = Reflux.createStore
init: ->
@state = @getInitialState()
@fetchThreads()
getInitialState: ->
loaded: false
threads: []
fetchThreads: ->
# ajax call for not Testing, and just trigger for Testing
@state.threads = FakeData.threads(20)
@state.loaded = true
setTimeout( =>
@trigger(@state) # This WILL work!
, 500)
遅滞なく機能しない理由を説明できますか? それはバグか、私が理解できないものですか。