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?
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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.