Skip to content

Instantly share code, notes, and snippets.

@NielsMasdorp
Last active June 1, 2018 07:47
Show Gist options
  • Save NielsMasdorp/ff5fca11e3019900c4fdc701f2dc0898 to your computer and use it in GitHub Desktop.
Save NielsMasdorp/ff5fca11e3019900c4fdc701f2dc0898 to your computer and use it in GitHub Desktop.
How to wrap an existing async API in a reactive stream
return Observable.create { emitter ->
      foo.fetchBar(object : FooCallback<Bar> {
          override fun onSuccess(bar: Bar) {
               emitter.onNext(bar)
          }

          override fun onError(error: Throwable) {
               emitter.onError(error)
          }
      })
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment