Created
June 23, 2017 10:25
-
-
Save joeyciechanowicz/22c3eef64ea62c1b3bf8b9892152e5d3 to your computer and use it in GitHub Desktop.
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
Observable.pairwise<T>(input : Observable<T> { | |
override fun call(subscriber: Subscriber<in T>) { | |
let prev, isInitialised = false; | |
input.subscribe(x -> { | |
if (isInitialised) | |
subscriber.onNext(new array[prev, x]); | |
prev = x; | |
} else { | |
isInitialised = true; | |
prev = curr; | |
} | |
}, | |
{ | |
subscriber.onCompleted() | |
} | |
); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment