Created
January 8, 2016 08:03
-
-
Save codeflows/e72568fd64d923a3ccfc to your computer and use it in GitHub Desktop.
groupBy for RxSwift
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
extension ObservableType { | |
func groupBy<G: Equatable>(predicate: E -> G) -> Observable<Observable<E>> { | |
return distinctUntilChanged(predicate).map { first in | |
return self.startWith(first).takeWhile { predicate($0) == predicate(first) } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment