Skip to content

Instantly share code, notes, and snippets.

@feresr
Last active Jan 30, 2017
Embed
What would you like to do?
multicast2
Observable<Data> dataStream = Observable.just(1)
.observeOn(Schedulers.io())
.debounce(2, TimeUnit.SECONDS)
.flatMap(new Func1<Integer, Observable<Data>>() {
@Override
public Observable<Data> call(Integer aVoid) {
Log.d(TAG, "Performing network request...");
return apiEndpoints.getData();
}
})
.observeOn(AndroidSchedulers.mainThread());
dataStream.subscribe(data -> Log.d(TAG, "View one received the data"));
dataStream.subscribe(data -> Log.d(TAG, "View two received the data"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment