<@U3H5152AW> could be smth like this with publishS...
# android
i
@viliusk could be smth like this with publishSubject
Copy code
private lateinit var publisher: PublishSubject<String>
Copy code
publisher
                .debounce(DEFAULT_DEBOUNCE_TIME, TimeUnit.MILLISECONDS)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe({ search(it) })
Copy code
fun onSearchTyped(term: String) {
             view!!.showLoading()
             publisher.onNext(term)
    }
Copy code
searchDisposable = searchShowsInput.execute(term)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe({
                    showData()
                }, {
                    view!!.showError()
                })
With this solution it’s possible to
dispose
previous result if api took longer then expected and search with new term
👍 1