Closed Jooc closed 4 years ago
func dispatch(_ action: AppAction) { #if DEBUG print("[ACTION]: \(action)") #endif let result = Store.reduce(state: appState, action: action) appState = result.0 if let command = result.1 { #if DEBUG print("[COMMAND]: \(command)") #endif command.execute(in: self) } }
以上代码是原书示例PokemonMaster 中Store 的dispatch 函数
但是在加载Pokemons 的LoadPokemonsCommand对应的excute() 函数里明明有通过sink 的回调闭包调用了该dispatch 函数
请问为什么appState = result.0 在运行时并没有出现“在非主线程中修改UI”的错误呢? (我自己尝试时出现了该警告
appState = result.0
是我忽略了什么细节吗?
Store 中的dispatch() 函数是static 函数,打扰了
以上代码是原书示例PokemonMaster 中Store 的dispatch 函数
但是在加载Pokemons 的LoadPokemonsCommand对应的excute() 函数里明明有通过sink 的回调闭包调用了该dispatch 函数
请问为什么
appState = result.0
在运行时并没有出现“在非主线程中修改UI”的错误呢? (我自己尝试时出现了该警告是我忽略了什么细节吗?