Last active
April 8, 2019 12:23
-
-
Save baldraider/c43729b24760ee9df1ccbce5e2b6d0be 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
//In this example no values will be published as the sequence never completes. No values will be written to the console. | |
fun asyncSubjectExample1(){ | |
var subject = new AsyncSubject<string>() | |
subject.onNext("a") | |
subject.onNext("b") | |
subject.onNext("c") | |
subject.subscribe(println(it)) | |
} | |
//In this example we invoke the OnCompleted method so the last value 'c' is written to the console: | |
fun asyncSubjectExample2(){ | |
var subject = new AsyncSubject<string>() | |
subject.onNext("a") | |
subject.onNext("b") | |
subject.onNext("c") | |
subject.onCompleted() | |
subject.subscribe(println(it)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment