4

We've used ReSwift in a few iOS projects and have been loving it. In 4.0, they added the ability to sub-select portions of the state and skipRepeats, either manually or using a store that's Equatable. Subselecting a store is straightforward:

store.subscribe(subscriber) {
  $0.select {
    $0.testValue
  }
}

Then you define newState with:

func newState(state:TestValue) {
   // handle new state
}

I'm a little stuck on how to define newState when passing multiple parameters via a tuple:

store.subscribe(subscriber) {
  $0.select {
    ($0.testValue, $0.otherState?.name)
  }
}

I'm passing the tuple but seeing the Type 'MainViewController' does not conform to protocol 'StoreSubscriber' and Type of expression is ambiguous without more context errors:

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

What am I doing incorrectly here?

topLayoutGuide
  • 1,407
  • 11
  • 22
shrug
  • 191
  • 1
  • 8

1 Answers1

4

Of course it was a simple mistake on my part. I needed to name the tuple that I was passing, in this example as state

func newState(state: (testState: TestValue, name: String)) {
    // handle new state
}
shrug
  • 191
  • 1
  • 8