Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from RuiAAPeres/rp/WillDeallocate
Deallocate Trigger Signal
- Loading branch information
Showing
4 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// RACSignal.swift | ||
// Rex | ||
// | ||
// Created by Rui Peres on 14/04/2016. | ||
// Copyright © 2016 Neil Pankey. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Result | ||
import ReactiveCocoa | ||
|
||
extension RACSignal { | ||
|
||
/// Converts `self` into a `Signal`. | ||
/// | ||
/// Because the operator can't know whether `self` is hot or cold, | ||
/// for certain things, like event streams (see `UIControl.signalForControlEvents`) | ||
/// use this method to be able to expose these inherently hot streams | ||
/// as `Signal`s. | ||
@warn_unused_result(message="Did you forget to call `observe` on the signal?") | ||
public func rex_toSignal() -> Signal<AnyObject?, NSError> { | ||
return Signal { observer in | ||
return self.toSignalProducer().start(observer) | ||
} | ||
} | ||
|
||
/// Converts `self` into a `Signal`, that can be used | ||
/// with the `takeUntil` operator, or as an "activation" signal. | ||
/// (e.g. a button) | ||
@warn_unused_result(message="Did you forget to call `observe` on the signal?") | ||
public final func rex_toTriggerSignal() -> Signal<(), NoError> { | ||
return self | ||
.rex_toSignal() | ||
.map { _ in () } | ||
.ignoreError() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters