Created
December 5, 2016 22:01
-
-
Save ragdroid/8f3a4d93f8c0a15b092c7dc289e2cf91 to your computer and use it in GitHub Desktop.
Use concatMap() to maintain order 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
//Use concat-Map() to maintain order while performing "Auto-Complete Search" | |
publishSubject | |
.debounce(300, TimeUnit.MILLISECONDS) | |
.concatMap(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