Skip to content

Instantly share code, notes, and snippets.

@novodimaporo
Last active August 30, 2017 07:21
Show Gist options
  • Save novodimaporo/06be7555fb579bd2a58392122f81a917 to your computer and use it in GitHub Desktop.
Save novodimaporo/06be7555fb579bd2a58392122f81a917 to your computer and use it in GitHub Desktop.
playing with rxjava2
fun observable1() =
Observable.fromCallable {
print("new callable 1\n")
true
}
fun observable2() =
Observable.fromCallable {
print("new callable 2\n")
true
}
fun observable3() =
Observable.interval(1, TimeUnit.SECONDS).map{1}
fun transformer() =
ObservableTransformer<Int, Unit> {
Observable.combineLatest(
observable1(),
observable2(),
it,
Function3 { t1, t2, t3 -> print("t1: $t1 t2: $t2 t3: $t3") }
)
}
fun main(args: Array<String>){
observable3().compose(transformer()).subscribe()
while (true) {}
}
@novodimaporo
Copy link
Author

novodimaporo commented Aug 30, 2017

The result

new callable 1
new callable 2
t1: true  t2: true  t3: 1
t1: true  t2: true  t3: 1
t1: true  t2: true  t3: 1
t1: true  t2: true  t3: 1
t1: true  t2: true  t3: 1
t1: true  t2: true  t3: 1
t1: true  t2: true  t3: 1
t1: true  t2: true  t3: 1
t1: true  t2: true  t3: 1
t1: true  t2: true  t3: 1
t1: true  t2: true  t3: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment