Skip to content

Instantly share code, notes, and snippets.

@feresr
Last active Jan 30, 2017
Embed
What would you like to do?
multicast3
Observable<Data> dataStream = RxView.clicks(button)
.observeOn(Schedulers.io())
.debounce(2, TimeUnit.SECONDS)
.flatMap(new Func1<Void, Observable<Data>>() {
@Override
public Observable<Data> call(Void aVoid) {
Log.d(TAG, "Performing network request...");
return apiEndpoints.getData();
}
})
.publish().autoConnect(2) // <-- NEW LINE
.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