我们已经在一些 iOS 项目中使用过ReSwift,并且一直很喜欢它。在4.0中,他们添加了子选择部分状态的功能,并且skipRepeats
可以手动或使用 Equatable 的存储。选择商店很简单:
store.subscribe(subscriber) {
$0.select {
$0.testValue
}
}
然后你定义newState
:
func newState(state:TestValue) {
// handle new state
}
newState
当通过元组传递多个参数时,我对如何定义有点困惑:
store.subscribe(subscriber) {
$0.select {
($0.testValue, $0.otherState?.name)
}
}
我正在传递元组,但看到Type 'MainViewController' does not conform to protocol 'StoreSubscriber'
andType of expression is ambiguous without more context
错误:
func newState((testState: TestValue, name: String)) {
// handle new state
}
我在这里做错了什么?