2017-07-10 2 views
3

私はいくつかのiOSプロジェクトでReSwiftを使用しており、それを愛しています。 4.0には、手動でまたはEquatableのストアを使用して、状態の一部とskipRepeatsをサブ選択する機能が追加されました。ストアをSubselectingするのは簡単です:私はタプルを介して複数のパラメータを渡すときnewStateを定義する方法の少しこだわっている複数のサブ選択でReSwiftで `newState`を定義するには?

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

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

は次にあなたが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 
} 

私はここで間違っていますか?

答えて

3

もちろん私のところでは簡単な間違いでした。この例では、渡していたタプルの名前をつける必要がありました。state

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

私は同じことを見ていました!ニースキャッチメイト:+1: – topLayoutGuide

関連する問題