Skip to content

Instantly share code, notes, and snippets.

@joeyciechanowicz
Created June 23, 2017 10:25
Show Gist options
  • Save joeyciechanowicz/22c3eef64ea62c1b3bf8b9892152e5d3 to your computer and use it in GitHub Desktop.
Save joeyciechanowicz/22c3eef64ea62c1b3bf8b9892152e5d3 to your computer and use it in GitHub Desktop.
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