macosswiftreactive-cocoa

Pipe Forward Operator in reactivecocoa missing in action and yes I have imported reactivecocoa


I am using Xcode 7.0.1 (7A1001) on Mac OsX 10.11

I using carthage 0.9.2 to download reactivecocoa with the following cartfile

github "ReactiveCocoa/ReactiveCocoa" "swift2"

When I had problems I switched to

github "ReactiveCocoa/ReactiveCocoa" "v4.0-alpha.1"

but still had the same problem

import ReactiveCocoa

let (signal1, sink1) = Signal<Int, NoError>.pipe()
let signal = signal1
    |> map { $0 + 1 }

Gives me a binary operator not found error in Xcode


Solution

  • By checking out the source code on the main v3.0.0 branch of reactivecocoa and comparing it to the code on the swift2 branch. It seems that the pipe forward operator is no more.

    You just replace the |> operator with a dot as follows.

    let (signal1, sink1) = Signal.pipe() let signal = signal1. map { $0 + 1 }

    After figuring this out for myself, of course I found the check in comment on the swift2 branch telling me that the pipe forward operator had been removed. When I switched from using the code on the main branch to using the code on the swift2 branch then I should have reread the documentation on the swift2 branch.

    All the code examples out there use the |> (pipe forward operator) this is going to cause confusion.