Skip to content

Instantly share code, notes, and snippets.

@faisalmohd83
Created December 14, 2018 08:39
Show Gist options
  • Save faisalmohd83/112a0d3b96d97ce6408961d9033907c2 to your computer and use it in GitHub Desktop.
Save faisalmohd83/112a0d3b96d97ce6408961d9033907c2 to your computer and use it in GitHub Desktop.
RxJava implementation - scope & detail.
Official : https://github.com/ReactiveX/RxAndroid
Observables/Flowable : https://github.com/balamaci/rxjava-walkthrough#flowable
AsyncTask replacement
https://medium.com/@kurtisnusbaum/rxandroid-basics-part-1-c0d5edcf6850
https://medium.com/@kurtisnusbaum/rxandroid-basics-part-2-6e877af352
Additional docs:
https://proandroiddev.com/offline-apps-its-easier-than-you-think-9ff97701a73f
Probable changes:
Replace AsyncTask in RecentList to load Recents from DB. [Observables would serve purpose]
Replace AsyncTask in Favourite list to load from SharedPrefs [Observables would serve purpose]
Replace Dialpad TextWatcher with AsycTask
Study possible API query to be transformed.
--
e.g.,
Observable/Flowable/Single well explained - https://android.jlelse.eu/be-reactive-develop-your-next-app-with-rxjava-4f00bfde0020
EditText AutoComplete - https://proandroiddev.com/building-an-autocompleting-edittext-using-rxjava-f69c5c3f5a40
private fun configureAutoComplete() {
autoCompletePublishSubject
.debounce(300, TimeUnit.MILLISECONDS)
.distinctUntilChanged()
.switchMap { autoCompleteApi.autoComplete(it) }
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ result ->
onAutoCompleteResultReceived(result)
}, { t: Throwable? -> Timber.w(t, "Failed to get search results") })
}
Observables/Flowable : https://github.com/balamaci/rxjava-walkthrough#flowable
Understanding RxJava Subject — (Publish, Replay, Behavior and Async Subject) - https://blog.mindorks.com/understanding-rxjava-subject-publish-replay-behavior-and-async-subject-224d663d452f
Suitable for Dialpad - https://medium.com/crunching-rxandroid/crunching-rxandroid-intro-c27eb6f009ea
RxJava: convert a listener into an Observable : http://www.andreamaglie.com/2015/rxjava-listener-to-observable/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment