Flow in-depth series: Using Kotlin Flows in ViewModels

? Flow in-depth series: Using Kotlin Flows in ViewModels ? Flow in-depth series: more intelligent sharing Kotlin Flows ? Flow in-depth series: the strategy of using Kotlin Flow to automatically refresh Android data After Flow appears, LiveData can still be used and can be converted to each other. Loading UI data in Android applications can […]

Flow in-depth series: Using Kotlin Flows in ViewModels

Flow in-depth series: Using Kotlin Flows in ViewModels Flow in-depth series: more intelligent sharing Kotlin Flows Flow in-depth series: Strategies for automatically refreshing Android data using Kotlin Flow Flow in-depth series: Using Kotlin Flows in ViewModels After Flow appears, LiveData can still be used and can be converted to each other. Loading UI data in […]

JetPack ViewModel understanding analysis

Article directory Ask a question: Why can viewmodel retain interface state? 1.Implementation principle of viewmodel 2. What is viewmodel 3.What is viewmodel used for? 4.What are the advantages of viewmodel? Ask a question: Why can viewmodel retain interface state 1.Implementation principle of viewmodel We all know that the activity will be rebuilt when the screen […]

Android Jetpack lifecycle aware component ViewModel

ViewModel Jetpack ViewModel is a component in the Android Jetpack component library, used to help developers manage UI-related data and status. The main role of ViewModel is to store and manage data related to the UI, and to handle state changes of the UI. Using ViewModel can solve the following problems: Avoid data loss caused […]

Android Jetpack component architecture: the principle of ViewModel

Android Jetpack component architecture: the principle of ViewModel Introduction This article is about introducing ViewModel. Since the use of ViewModel is quite simple, its basic application will not be introduced here. We will mainly analyze the principle of ViewModel. ViewModel life cycle As we all know, ViewModel is generally used to solve two problems. The […]

Jetpack business architecture-four-piece set (Lifecycle, ViewModel, LiveData, DataBinding)

Jetpack is a suite of libraries that help developers follow best practices, reduce boilerplate code, and write code that runs consistently across Android versions and devices, allowing developers to focus on what really matters. Coding work. Advantages of Android Jetpack components: The main purpose of Jetpack is to enable developers to complete product development more […]

Basic use of ViewModel

Directory 1. Basic use 2. Combined use of ViewModel + DataBinding + LiveData 1. java version 2. kotlin version The responsibility of ViewModel is to ensure the stability of the data in the View layer 1. Basic usage Import ViewModel dependencies in build.gradle in the app directory implementation ‘androidx.lifecycle:lifecycle-extensions:2.2.0’ MyViewModel.kt package com.example.myviewmodel import androidx.lifecycle.ViewModel class […]

View ViewModel life cycle monitoring from LeakCanary

In the previous two articles, we have learned about the implementation of Service and Fragment life cycle monitoring in LeakCanary, so how is ViewModel life cycle monitoring realized? Similarly, to understand ViewModel lifecycle monitoring, we should first understand how the ViewModel is stored and acquired in the code structure, and when the ViewModel object will […]