我们在一些iOS项目中使用了ReSwift并一直很喜欢它。在4.0中,他们添加了手动或使用Equatable商店来选择状态和skipRepeats部分的功能。子选择商店很简单:

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'Type of expression is ambiguous without more context错误:
func newState((testState: TestValue, name: String)) {
    // handle new state
}

我在这里做错了什么?

最佳答案

当然,这对我来说是一个简单的错误。我需要将要传递的元组命名为state

func newState(state: (testState: TestValue, name: String)) {
    // handle new state
}

10-08 06:53