eucalypto / learn

These are projects that help me learn
0 stars 0 forks source link

Architecture Components ViewModel & LiveData: Unscramble App (codelabs) #41

Open eucalypto opened 2 years ago

eucalypto commented 2 years ago

Project Files

Architecture Components Pathway

Original github repository: https://github.com/google-developer-training/android-basics-kotlin-unscramble-app

eucalypto commented 2 years ago

Codelab 1: Store data in ViewModel

eucalypto commented 2 years ago

I like the starter code already: it follows clean code principles! (Unlike many other codelabs projects). Only because it wants to show a certain technique, does not mean that common coding practices have to be ignored. :) Otherwise newbies may subconsciously learn that it's OK to put everything in a god-like onCreateView() of a fragment.

eucalypto commented 2 years ago

I'm using a DialogFragment to get all the automatic features of it. Here, I'm using by activityViewModels() to share the view model, but I don't want to scope my view model to the activity.

Here's a proposed better solution: https://stackoverflow.com/questions/63225618/android-share-viewmodel-between-fragment-and-dialog-fragment

eucalypto commented 2 years ago

This concludes Codelab 1: Store data in ViewModel

eucalypto commented 2 years ago

Codelab 2: Use LiveData with ViewModel