Edward Ashak
Edward Ashak

Reputation: 2421

Having trouble binding MutableProperty<String> to a Signal<String, NoError> with RAC 3.0

So I'm trying to bind this mutable property to the string signal.

func bindViewModel() {
    let stringProp = MutableProperty<String>("")
    let (stringSignal, stringSink) = Signal<String, NoError>.pipe()

    stringProp <~ stringSignal
}

My understanding is that the types match with this function signature:

func <~<P : MutablePropertyType>(property: P, signal: ReactiveCocoa.Signal<P.Value, ReactiveCocoa.NoError>) -> Disposable

Yet the compiler seems confused about which operator to use and prints out this error:

error: ambiguous operator declarations found for operator
        stringProp <~ stringSignal
                   ^

the types seem to checkout in my opinion but not according to the compiler ... Any idea how to resolve this bind ?

Upvotes: 0

Views: 391

Answers (1)

Edward Ashak
Edward Ashak

Reputation: 2421

it appears the compiler is unable to distinguish between the ReactiveCocoa.<~ and

infix operator <~ {}
public func <~ (rac: RAC, signal: RACSignal) {
    rac.assignSignal(signal)
}

which was create by Created by Colin Eberhardt.

I am not sure yet how to work around it. the arguments are completely different ...

--- EDIT ----

infix operator <~ {
associativity right
precedence 93
}
public func <~ (rac: RAC, signal: RACSignal) {
    rac.assignSignal(signal)
}

Seems like Ash Furrow already solved this. Found this in GitHub search.

Apparently setting both operators to the same priority forces the compiler to pick the right function.

Upvotes: 0

Related Questions