How to define `newState` in ReSwift with multiple subsamples?

We have used ReSwift on several iOS projects and loved it. In 4.0 they added the ability to subsection the individual pieces of state and skipRepeats

, either manually or using Equatable storage, Allocating storage is straightforward:

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

      

Then you define newState

with:

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

      

I got a bit stuck on how to determine newState

when passing multiple parameters through a tuple:

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

      

I am passing in a tuple, but I see errors Type 'MainViewController' does not conform to protocol 'StoreSubscriber'

and Type of expression is ambiguous without more context

:

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

      

What am I doing wrong here?

+3


source to share


1 answer


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



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

      

+3


source







All Articles