В Hilt появилась возможность использовать Assisted Injection для ViewModel, чтобы передавать свои объекты в конструктор модели.
#android #dagger #hilt #viewmodel
https://medium.com/@alexander.michaud/hiltviewmodel-assisted-injection-with-compose-a800723165bf
#android #dagger #hilt #viewmodel
https://medium.com/@alexander.michaud/hiltviewmodel-assisted-injection-with-compose-a800723165bf
👍20🤮13🤯4
  Статья о технической реализации UI событий в ViewModel
#android #viewmodel #architecture #event
https://proandroiddev.com/viewmodel-events-as-state-are-an-antipattern-35ff4fbc6fb6 (Оригинал)
https://shorturl.at/dghip (Перевод)
  
  #android #viewmodel #architecture #event
https://proandroiddev.com/viewmodel-events-as-state-are-an-antipattern-35ff4fbc6fb6 (Оригинал)
https://shorturl.at/dghip (Перевод)
Medium
  
  ViewModel: Events as State are an Antipattern
  In this article Nikita explores how a popular notion about expressing events as states may be a misleading one.
👍7🤔3👎2🥱2🤯1
  В третьей части серии статей о ViewModel Best Practices обсуждают следующие пункты:
- Try not to import Android dependencies in the ViewModels:
- Lazily inject dependencies in the constructor.
#android #viewmodel
https://proandroiddev.com/mastering-android-viewmodels-essential-dos-and-donts-part-3-%EF%B8%8F3%EF%B8%8F%E2%83%A3-1833ce3ddd2b
- Try not to import Android dependencies in the ViewModels:
- Lazily inject dependencies in the constructor.
#android #viewmodel
https://proandroiddev.com/mastering-android-viewmodels-essential-dos-and-donts-part-3-%EF%B8%8F3%EF%B8%8F%E2%83%A3-1833ce3ddd2b
🔥10👍6
  Вторая часть статьи про начальную загрузку данных в ViewModel. Отвечает на самые распространенные вопросы, возникшие после первой части.
1. What if you want to pass arguments when loading initial data
2. What if you want to refresh?
3. Why are ViewModel.init side-effects potentially problematic?
4. How to prevent re-emitting flow from WhileSubscribed(5_000)
#android #viewmodel #architecture #bestpractice
https://proandroiddev.com/loading-initial-data-part-2-clear-all-your-doubts-0f621bfd06a0
  
  1. What if you want to pass arguments when loading initial data
2. What if you want to refresh?
3. Why are ViewModel.init side-effects potentially problematic?
4. How to prevent re-emitting flow from WhileSubscribed(5_000)
#android #viewmodel #architecture #bestpractice
https://proandroiddev.com/loading-initial-data-part-2-clear-all-your-doubts-0f621bfd06a0
Medium
  
  Loading Initial Data on Android Part 2: Clear All Your Doubts
  When a user enters a screen, the default data should be fetched by triggering the business logic, whether from the network or local…
👍12🎉3👎1
  Dos and Don’ts для ViewModel, часть 5:
- Avoid hardcoding Coroutine Dispatchers.
- Unit test your ViewModels.
- Avoid exposing suspended functions.
#kotlin #android #viewmodel #bestpractise
https://proandroiddev.com/mastering-android-viewmodels-essential-dos-and-donts-part-5-%EF%B8%8F5%EF%B8%8F%E2%83%A3-14d04ec2426a
  
  - Avoid hardcoding Coroutine Dispatchers.
- Unit test your ViewModels.
- Avoid exposing suspended functions.
#kotlin #android #viewmodel #bestpractise
https://proandroiddev.com/mastering-android-viewmodels-essential-dos-and-donts-part-5-%EF%B8%8F5%EF%B8%8F%E2%83%A3-14d04ec2426a
Medium
  
  Mastering Android ViewModels: Essential Dos and Don’ts Part 5 🛠️5️⃣
  keep these in mind for better code quality when doing ViewModels!
❤4👍4🥰1
  Автор попытался создать ViewModel со временем жизни Composable функции. Штука, может и ненужная, но интересная, чтобы лучше понимать и Compose и ViewModel.
#android #compose #viewmodel #lifecycle
https://proandroiddev.com/composable-scoped-viewmodel-an-interesting-experiment-b982b86d84cd
  
  #android #compose #viewmodel #lifecycle
https://proandroiddev.com/composable-scoped-viewmodel-an-interesting-experiment-b982b86d84cd
Medium
  
  Composable-scoped ViewModel: An interesting experiment
  Scope any ViewModel to the composition of the Composable it is in, while surviving configuration changes, by using the power of Lifecycle.
🤯8👍7🔥2😱1
  ViewModelScenario - поможет протестить Lifecycle кейсы вью-модели
Доступен с Lifecycle 2.9.0-alpha08.
#android #viewmodel #test
https://medium.com/androiddevelopers/unit-testing-lifecycle-and-state-in-viewmodels-9d406c08cbd7
  
  Доступен с Lifecycle 2.9.0-alpha08.
#android #viewmodel #test
https://medium.com/androiddevelopers/unit-testing-lifecycle-and-state-in-viewmodels-9d406c08cbd7
Medium
  
  Unit Testing Lifecycle and State in ViewModels
  Simplify Android ViewModel testing with ViewModelScenario, now available for catching cleanup and saved state errors.
👍8
  Еще одна статья о том, как правильно грузить данные в ViewModel
#android #viewmodel #architecture #bestpractice
https://proandroiddev.com/how-to-load-data-kotlin-898f9add9c6f
  
  #android #viewmodel #architecture #bestpractice
https://proandroiddev.com/how-to-load-data-kotlin-898f9add9c6f
Medium
  
  Stale Data & Leaks were killing my Kotlin apps for 5 years. Here’s the fix.
  This is the last article you’ll ever read on loading data in Kotlin.
👍9❤3👎1🤔1
  Обзор новой Compose функции - retain. Похоже на функцию remember с временем жизни ViewModel. 
#compose #lifecycle #viewmodel #retain #remember
https://proandroiddev.com/exploring-retain-api-a-new-way-to-persist-state-in-jetpack-compose-bfb2fe2eae43
  
  #compose #lifecycle #viewmodel #retain #remember
https://proandroiddev.com/exploring-retain-api-a-new-way-to-persist-state-in-jetpack-compose-bfb2fe2eae43
Medium
  
  Previewing retain{} API: A New Way to Persist State in Jetpack Compose
  Jetpack Compose has reshaped how we think about UI in Android. With its declarative nature, reactive state model, and composable functions…
👍10
  Автор приводит минусы загрузки данных в ViewModel.init и рассматривает Flow-based решение на замену
#android #viewmodel #architecture #bestpractise
https://funkymuse.dev/posts/properly-load-data/
  
  #android #viewmodel #architecture #bestpractise
https://funkymuse.dev/posts/properly-load-data/
FunkyMuse
  
  Android ViewModel Data Loading: Best Practices and Flow-Based Architecture
  Architecture discussions in Android development often spark passionate debates—sometimes garnering both praise and criticism. Writing about these topics isn’t easy, but that’s what makes it worthwhile.
1❤9