Created
January 1, 2018 23:25
-
-
Save twittemb/0183159ef21e81d077d3ec77a6fdff92 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| extension ObservableType { | |
| /// Pauses the elements of the source observable sequence based on | |
| /// the latest element from the second observable sequence. | |
| /// Elements are ignored unless the second sequence has most recently | |
| /// emitted `true`. | |
| /// - Parameter pauser: The observable sequence used to pause the source | |
| /// observable sequence. | |
| /// - Returns: The observable sequence which is paused based upon | |
| /// the pauser observable sequence. | |
| public func pausable<P: ObservableType> ( _ pauser: P) -> Observable<E> | |
| where P.E == Bool { | |
| return withLatestFrom(pauser) { element, paused in | |
| (element, paused) | |
| }.filter { _, paused in | |
| paused | |
| }.map { element, _ in | |
| element | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment