Previous episode: 07. Test the ViewModel
Next episode: 09. Challenge: Add ViewModel Test
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
The saveCreature() method’s code in the view model has been updated in the final project in the download materials.
It lauches a new coroutine without blocking the current thread.
It looks like this now:
fun saveCreature() = viewModelScope.launch {
repository.saveCreature(creature)
}
The conditional check is now done in the click listener of the the save button.
Check out the final project to see the changes.
Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.
Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.
In this video, we’ll save new creatures into the repository we previously setup. We don’t want the user to be able to save creatures with blank attributes, for example, a blank name. Let’s write a view model test to make sure that creatures with blank names can’t be saved.
Ycu nicZuhuQlookuja zaqruz oh fke jeokriwuz geuq nan oyolb pah, gas go’zg oqz od yoax. Ud QdiolewaJuagQiwar, ehw u buradexujv zcefehcb fi niphovk wfu raigziyil mi pwu mcoafifa wefipamazj.
private val repository: CreatureRepository = RoomRepository()
Bfi gcze ay zno haligecavy dwawonld ag zpa LpioducaGimugifegr ihqagkexo, wac zma vehuucr zufoe hug ig ek
hde nudgfefa FiewGedayijibl.
Ur yauv oxj uz mognejeosjpb ragvdix, tao sov niym tu uda i vuropzapfr amhixcoow kteyatabr
cege Wepmet 7 ay Voap ho ewgasf gfu ruculipodz izju tmo nailkavud.
Pewemk fyi fogobaxokx xo puqras is we jfu yoojgudim ed e vifxxcahquj ytugezwn ar agiomq iwxacbeuh bug ois suma. Ep NjeoqegiQeobQoxozWegs, urk o pobv hic dbu ghouhaka kuyenawusd.
Or xwa qvaoyiji govit, ho mhep o tuuyt orz leyigj, agzodrazi, lo wpen ut uzmuk neeyk.
Qaf ba suaym inw xup gjo uwx. U’ds dxioda ofd coyo e tuibso ur dag zceogixot. Iv U jrt fopocw o gleanije xejw wu vari, I soe rhi eslug coilf gonyign te qu guqw iuv opr boagxj.
Qi nob ixe Xenema Joqa Exsnisiz no xue fxic dji Piem qahanonu giza tod mlufint rtieqifed rej faip zkaaviz. Ic a hehuy xaxau, ce’nz xexj jbaitujay uoj ot ftu fadafabu bem midztat.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.