Added discardableResult.

This commit is contained in:
Tyler Cloutier 2016-06-19 23:01:22 -07:00
parent 36e5cccc75
commit a4a12d3cba
2 changed files with 13 additions and 2 deletions

View File

@ -116,6 +116,7 @@ extension ColdSignalType {
/// invokes start on the ColdSignal.
///
/// Returns a Disposable which can be used to dispose of the added observer.
@discardableResult
public func start(with observer: Observer<Value, Error>) -> Disposable? {
let disposable = add(observer: observer)
start()
@ -126,6 +127,7 @@ extension ColdSignalType {
/// invokes start on the ColdSignal.
///
/// Returns a Disposable which can be used to dispose of the added observer.
@discardableResult
public func start(_ observerAction: Observer<Value, Error>.Action) -> Disposable? {
return start(with: Observer(observerAction))
}
@ -134,6 +136,7 @@ extension ColdSignalType {
/// invokes start on the ColdSignal.
///
/// Returns a Disposable which can be used to dispose of the added observer.
@discardableResult
public func startWithNext(next: (Value) -> Void) -> Disposable? {
return start(with: Observer(next: next))
}
@ -142,6 +145,7 @@ extension ColdSignalType {
/// immediately invokes start on the ColdSignal.
///
/// Returns a Disposable which can be used to dispose of the added observer.
@discardableResult
public func startWithCompleted(completed: () -> Void) -> Disposable? {
return start(with: Observer(completed: completed))
}
@ -150,6 +154,7 @@ extension ColdSignalType {
/// immediately invokes start on the ColdSignal.
///
/// Returns a Disposable which can be used to dispose of the added observer.
@discardableResult
public func startWithFailed(failed: (Error) -> Void) -> Disposable? {
return start(with: Observer(failed: failed))
}
@ -158,8 +163,9 @@ extension ColdSignalType {
/// immediately invokes start on the ColdSignal.
///
/// Returns a Disposable which can be used to dispose of the added observer.
@discardableResult
public func startWithInterrupted(interrupted: () -> Void) -> Disposable? {
return start(with: Observer(interrupted: interrupted))
}
}
}

View File

@ -176,6 +176,7 @@ extension SignalType {
/// Convenience override for add(observer:) to allow trailing-closure style
/// invocations.
@discardableResult
public func on(action: Observer<Value, Error>.Action) -> Disposable? {
return add(observer: Observer(action))
}
@ -186,6 +187,7 @@ extension SignalType {
/// Returns a Disposable which can be used to stop the invocation of the
/// callbacks. Disposing of the Disposable will have no effect on the Signal
/// itself.
@discardableResult
public func onNext(next: (Value) -> Void) -> Disposable? {
return add(observer: Observer(next: next))
}
@ -196,6 +198,7 @@ extension SignalType {
/// Returns a Disposable which can be used to stop the invocation of the
/// callback. Disposing of the Disposable will have no effect on the Signal
/// itself.
@discardableResult
public func onCompleted(completed: () -> Void) -> Disposable? {
return add(observer: Observer(completed: completed))
}
@ -206,6 +209,7 @@ extension SignalType {
/// Returns a Disposable which can be used to stop the invocation of the
/// callback. Disposing of the Disposable will have no effect on the Signal
/// itself.
@discardableResult
public func onFailed(error: (Error) -> Void) -> Disposable? {
return add(observer: Observer(failed: error))
}
@ -217,6 +221,7 @@ extension SignalType {
/// Returns a Disposable which can be used to stop the invocation of the
/// callback. Disposing of the Disposable will have no effect on the Signal
/// itself.
@discardableResult
public func onInterrupted(interrupted: () -> Void) -> Disposable? {
return add(observer: Observer(interrupted: interrupted))
}
@ -257,4 +262,4 @@ extension SignalType {
}
}
}
}
}