![]() ![]() String ENDPOINT = reposForUser String user) Previously, we defined our interface for accessing the GitHub API like so. : When/If we get data back from our Rest API (Model Layer) Now we’ll refactor the code, starting with our networking call. * we have to set the call adapter to RxJavaCallAdapter.Ĭompile '2:adapter-rxjava2:2.2.0' * To convert Retrofit "Call" objects to return type "Observable", * the background thread and the main thread on your observable's completion.Ĭompile 'io.reactivex.rxjava2:rxandroid:2.0.1' * AndroidSchedulers.mainThread() which allows you to switch between * Rx Android adds android specific bindings for RxJava. The first step we’ll take is adding the reactive libraries to our app’s adle /*Ĭompile 'io.reactivex.rxjava2:rxjava:2.0.8' ![]() When the user scrolls to the end of the list and so on and so forth…įor now we will only concern ourselves with the first three events. If the user clicks any items in the returned dataĦ. When results are first displayed to the userĥ. We want to keep this example simple, but there are so many other events/observables we could be monitoring, such as:Ĥ. When the user hits the “Submit” button (View Layer) Text being written in the EditText (View Layer)ģ. ![]() When or if we get data back from our Rest API (Model Layer)Ģ. Some examples of possible events/Observables are:ġ. I have left the posts up as they do provide a good understanding of reasoning behind the use of the MVVM pattern. That and the replacement of Java with Kotlin, means the code examples shown are no longer applicable. UPDATE : Shortly after starting this series, Android development underwent a major shift with Google releasing Android Architecture Components which provided a standard boilerplate for designing Android apps. So what events should we be observing and responding to? Or, thinking in Reactive Programming terms, what are our Observables? ![]() It’s time to go reactive! For our tutorial series, we are building a simple app which accepts a username, accesses the Github REST API and displays the user’s repos. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |