Skip to content

Commit 0c8af48

Browse files
authored
Merge pull request #153 from ReactiveCocoa/as-labelled-pipe
Proposal: Label the output and input ends of Signal.pipe()
2 parents d01a25e + 631b058 commit 0c8af48

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

Sources/Signal.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -265,19 +265,20 @@ public final class Signal<Value, Error: Swift.Error> {
265265
}
266266
}
267267

268-
/// Create a Signal that will be controlled by sending events to the given
269-
/// observer.
268+
/// Create a `Signal` that will be controlled by sending events to an
269+
/// input observer.
270270
///
271-
/// - note: The Signal will remain alive until a terminating event is sent
272-
/// to the observer, or until it has no observer if it is not
273-
/// retained.
271+
/// - note: The `Signal` will remain alive until a terminating event is sent
272+
/// to the input observer, or until it has no observers and there
273+
/// are no strong references to it.
274274
///
275275
/// - parameters:
276276
/// - disposable: An optional disposable to associate with the signal, and
277277
/// to be disposed of when the signal terminates.
278278
///
279-
/// - returns: A tuple made of signal and observer.
280-
public static func pipe(disposable: Disposable? = nil) -> (Signal, Observer) {
279+
/// - returns: A tuple of `output: Signal`, the output end of the pipe,
280+
/// and `input: Observer`, the input end of the pipe.
281+
public static func pipe(disposable: Disposable? = nil) -> (output: Signal, input: Observer) {
281282
var observer: Observer!
282283
let signal = self.init { innerObserver in
283284
observer = innerObserver

Tests/ReactiveSwiftTests/FlattenSpec.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Quick
1212
import ReactiveSwift
1313

1414
private extension SignalProtocol {
15-
typealias Pipe = (signal: Signal<Value, Error>, observer: Observer<Value, Error>)
15+
typealias Pipe = (output: Signal<Value, Error>, input: Observer<Value, Error>)
1616
}
1717

1818
private typealias Pipe = Signal<SignalProducer<Int, TestError>, TestError>.Pipe
@@ -26,7 +26,7 @@ class FlattenSpec: QuickSpec {
2626

2727
beforeEach {
2828
pipe = Signal.pipe()
29-
disposable = pipe.signal
29+
disposable = pipe.output
3030
.flatten(flattenStrategy)
3131
.observe { _ in }
3232
}
@@ -40,25 +40,25 @@ class FlattenSpec: QuickSpec {
4040

4141
beforeEach {
4242
disposed = false
43-
pipe.observer.send(value: SignalProducer<Int, TestError> { _, disposable in
43+
pipe.input.send(value: SignalProducer<Int, TestError> { _, disposable in
4444
disposable += ActionDisposable {
4545
disposed = true
4646
}
4747
})
4848
}
4949

5050
it("should dispose inner signals when outer signal interrupted") {
51-
pipe.observer.sendInterrupted()
51+
pipe.input.sendInterrupted()
5252
expect(disposed) == true
5353
}
5454

5555
it("should dispose inner signals when outer signal failed") {
56-
pipe.observer.send(error: .default)
56+
pipe.input.send(error: .default)
5757
expect(disposed) == true
5858
}
5959

6060
it("should not dispose inner signals when outer signal completed") {
61-
pipe.observer.sendCompleted()
61+
pipe.input.sendCompleted()
6262
expect(disposed) == false
6363
}
6464
}

0 commit comments

Comments
 (0)