Last active
January 30, 2017 21:53
-
-
Save feresr/b1e1045d175eae60f4fdce054fa9b6f9 to your computer and use it in GitHub Desktop.
multicast3
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
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