How to create an Rx Search view that will filter a recycler view with a query
<p>I want to implement a Rx Search view that will filter a recycler view with the string and also check the local Realm db and make a retrofit request, then combines all the results without duplicates ?? So, in other words: I would like to on text change event in a search view, to use the input string to make a network request, a db query and combine with results without duplicates</p>

<p>This is my initial code:</p>

<pre><code>RxSearchView.queryTextChanges(searchView)
            .filter(charSequence -&gt; !TextUtils.isEmpty(charSequence))
            .throttleLast(100, TimeUnit.MILLISECONDS)
            .debounce(200, TimeUnit.MILLISECONDS)
            .onBackpressureLatest()
            .flatMap(charSequence -&gt; userListPresenter.search(charSequence))
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeOn(Schedulers.io())
            .onErrorResumeNext(Observable.empty())
            .subscribe((Action1) response -&gt; userListPresenter.showSearchResult((List&lt;UserModel&gt;) response));
</code></pre>

<p>The userListPresenter.search(charSequence)) should return an observable of the concatenated response without duplicates, thanks :)</p>

<p>userListPresenter.search(charSequence)):</p>

<pre><code>Observable.create(subscriber -&gt; {
        if (Utils.isNetworkAvailable(getContext())) {
            if (!subscriber.isUnsubscribed()) {
                subscriber.onNext(restApi.search(query));
                subscriber.onCompleted();
            }
        }).mergeWith(
                    Observable.create(subscriber -&gt; {
        if (!subscriber.isUnsubscribed()) {
            subscriber.onNext(realmManager.getWhere(query));
            subscriber.onCompleted();
        }
    })).collect(HashSet::new, HashSet::add)
            .flatMap(Observable::from);
</code></pre>