Created
December 5, 2016 22:02
-
-
Save ragdroid/1f3223a0b9dbd3f5a29780ca31aff4e0 to your computer and use it in GitHub Desktop.
Order is not maintain if we use flatMap() while performing "Auto-Complete Search" .
This file contains hidden or 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
//Order is not maintain if we use flatMap() while performing "Auto-Complete Search" | |
publishSubject | |
.debounce(300, TimeUnit.MILLISECONDS) | |
.flatMap(new Function<String, ObservableSource<List<Book>>>() { | |
@Override | |
public ObservableSource<List<Book>> apply(String s) throws Exception { | |
Log.d(TAG, "getting books for " + s); | |
return dataSource.getBook(s); | |
} | |
}) | |
.subscribeOn(provider.io()) | |
.observeOn(provider.ui()) | |
.subscribe(new Consumer<List<Book>>() { | |
@Override | |
public void accept(List<Book> books) throws Exception { | |
onBooksFetched(books); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment