Created
July 25, 2018 06:48
-
-
Save elizarov/1c2d28a0feabac6814b599eb1a7cb276 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
import kotlinx.coroutines.experimental.delay | |
import kotlinx.coroutines.experimental.rx1.awaitFirst | |
import kotlinx.coroutines.experimental.rx1.rxObservable | |
import java.util.concurrent.TimeUnit | |
fun fetchFromNetwork() = rxObservable { | |
delay(1, TimeUnit.HOURS) | |
send("Result from network") | |
} | |
fun getResult() = rxObservable { | |
val result = fetchFromNetwork().awaitFirst() | |
send("network" in result) | |
} | |
fun main(args: Array<String>) { | |
val subscription = getResult().subscribe() | |
subscription.unsubscribe() | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment