Skip to content

Instantly share code, notes, and snippets.

@baldraider
Last active April 8, 2019 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baldraider/c43729b24760ee9df1ccbce5e2b6d0be to your computer and use it in GitHub Desktop.
Save baldraider/c43729b24760ee9df1ccbce5e2b6d0be to your computer and use it in GitHub Desktop.
//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