4

我们已经在一些 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
}

我在这里做错了什么?

4

1 回答 1

4

当然,这只是我的一个简单错误。我需要命名我传递的元组,在这个例子中state

func newState(state: (testState: TestValue, name: String)) {
    // handle new state
}
于 2017-07-10T14:33:50.153 回答