filmov
tv
Android Tutorial 2019 #7: Implementing ViewModel w/ MutableLiveData, Kotlin Coroutines, MVVM

Показать описание
Master OOP languages with tutorials from someone who actually cares if you understand how to write beautiful code:
All the above courses are available for 2.99 a month via a youtube subscription to this channel too!
In This part of the tutorial, we build the ViewModel portion of our Model-View-ViewModel architecture. As discussed in other episodes, we use a particular style of MVVM in this feature, where the View is kept very simple, but at the cost of losing reusability of a given ViewModel.
I will be going in to more detail about Coroutines in a separate video in this series, but I also talk about setting up a CoroutineScope so that we can launch coroutines and call suspending functions from the ViewModel. There's a shit ton of information in this video, so I've provided timestamps below:
4:42 Tip from Al Warren on hiding MutableLiveData objects behind immutable LiveData references
Al's blog:
6:35 Quick note on two functions in the ViewModel which we won't be coding today, but I will demonstrate it in another video
7:35 How to simplify interactions between the View and the ViewModel using Sealed Classes an Generics **PRO TIP**
8:54 Writing the constructor of our ViewModel
10:47 Adding the Repository to our ViewModel's Constructor.
11:10 Adding our MutableLiveData objects to the ViewModel
11:56 A very brief explanation of LiveData and MutableLiveData, and the differences between them
13:28 Representing on screen widgets and control logic using MutableLiveData
14:29 How to publish events to the View which do not require actually passing any data using Kotlin's Unit function
16:10 Adding a MutableLiveData object for each on-screen widget
18:20 Implementing our handleEvent Function with Sealed Class events
22:11 Implementing our Coroutine launch getUser() function (this is how we talk to the back end of the app using coroutines)
23:47 What is a Result Wrapper and why are we returning it from the backend?
25:21 Getting our User object out of the Result Wrapper, and assigning it to the MutableLiveData object
27:45 Implementing onAuthButtonClick Coroutine function
31:10 Implementing our Presentation Logic Functions (different states of the View) with const val String resources
Repository link:
MVVM Article:
Follow the wiseAss Community:
Support wiseAss here:
All the above courses are available for 2.99 a month via a youtube subscription to this channel too!
In This part of the tutorial, we build the ViewModel portion of our Model-View-ViewModel architecture. As discussed in other episodes, we use a particular style of MVVM in this feature, where the View is kept very simple, but at the cost of losing reusability of a given ViewModel.
I will be going in to more detail about Coroutines in a separate video in this series, but I also talk about setting up a CoroutineScope so that we can launch coroutines and call suspending functions from the ViewModel. There's a shit ton of information in this video, so I've provided timestamps below:
4:42 Tip from Al Warren on hiding MutableLiveData objects behind immutable LiveData references
Al's blog:
6:35 Quick note on two functions in the ViewModel which we won't be coding today, but I will demonstrate it in another video
7:35 How to simplify interactions between the View and the ViewModel using Sealed Classes an Generics **PRO TIP**
8:54 Writing the constructor of our ViewModel
10:47 Adding the Repository to our ViewModel's Constructor.
11:10 Adding our MutableLiveData objects to the ViewModel
11:56 A very brief explanation of LiveData and MutableLiveData, and the differences between them
13:28 Representing on screen widgets and control logic using MutableLiveData
14:29 How to publish events to the View which do not require actually passing any data using Kotlin's Unit function
16:10 Adding a MutableLiveData object for each on-screen widget
18:20 Implementing our handleEvent Function with Sealed Class events
22:11 Implementing our Coroutine launch getUser() function (this is how we talk to the back end of the app using coroutines)
23:47 What is a Result Wrapper and why are we returning it from the backend?
25:21 Getting our User object out of the Result Wrapper, and assigning it to the MutableLiveData object
27:45 Implementing onAuthButtonClick Coroutine function
31:10 Implementing our Presentation Logic Functions (different states of the View) with const val String resources
Repository link:
MVVM Article:
Follow the wiseAss Community:
Support wiseAss here:
Комментарии