viewmodel Questions

3

Solved

I watch some tutorial projects on YouTube and some of them make viewmodel file and write some bunch of code, just to use viewmodel! We have remember and rememberSavable and state and recomposition ...

3

I have a UseCase and remote repository that return Flow in a loop and I collect the result of UseCase in the ViewModel like this: viewModelScope.launch { useCase.updatePeriodically().collect { res...
Bonzer asked 30/5, 2021 at 15:46

2

Solved

As shown above, the list of items, the text input field and the add button go up when the user open the keyboard, I want the list of items to stay in position while the text input field and the ad...

5

Solved

I'm doing the same as shown in the documentation here. I want to Inject the ViewModel into a Composable function (Screen), but I get this error: Cannot create an instance of class com.example.blot...
Twelve asked 20/4, 2021 at 13:34

3

Solved

I'm currently working on a project to practice dependency injection with Dagger-Hilt, however I can't get my ViewModel to instantiate, I've already looked at some other questions on the same topic,...
Then asked 25/5, 2022 at 18:10

2

Solved

I have a screen that loads a bunch of requests and collects some data from the user on the same screen and an external WebView. Therefore, I have a ViewModel that contains these complex request obj...

2

I am trying to create MVVM app using Openweathermap API and hilt. I tried to inject my repository into my viewmodel primary constractor and creating a ViewModelFactory class, in order to pass the p...
Misdoing asked 13/2, 2022 at 21:27

4

Solved

With the introduction of the Android Architecture Components library, several new classes were introduced, including AndroidViewModel and ViewModel. However, I'm having trouble figuring out the dif...

16

Solved

I am new to ASP.NET MVC. I have a problem with understanding the purpose of a ViewModel. What is a ViewModel and why do we need a ViewModel for an ASP.NET MVC Application? If I get a good examp...
Salver asked 16/6, 2012 at 14:36

14

I have been trying to create an Object of ViewModel in an Activity but ViewModelProviders is deprecated So what's the alternative to create the ViewModel's object.
Lainelainey asked 17/8, 2019 at 8:46

1

I have a composable function named 'Page' as a basic composable to hold NavHost for my app, please see architecture below: @Composable fun Page(viewModel: LdvToolViewModel = hiltViewModel(), scaffo...
Chrysoprase asked 3/8, 2022 at 5:31

3

Solved

I'm trying to retrieve a single entry from the Database and successfully getting the value back in my View Model with the help of viewModelScope, but I want this value to be returned back to the ca...
Graeme asked 29/3, 2020 at 6:44

3

Android Architecture Components provide the LiveData and ViewModel classes which are more lifecycle-friendly and designed for a leaner Activity/Fragment. These classes handle storing data across co...

3

Solved

I'm working with ViewModels and LiveData in an Android app, and I want to use them to keep track of data for an Activity even when the screen is rotated. This works quite well, but there's one issu...
Teddy asked 8/2, 2019 at 12:49

4

I'm using android AAC library and Android databinding library in my project. I have AuthActivity and AuthViewModel extends android's ViewModel class. In some cases i need to ask for Activity to cal...
Toein asked 26/9, 2017 at 14:42

2

Solved

As per documentation for Hilt, I completed all the steps Add Class Path to Project Module classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version" Add Plugins plugins { id...
Allaallah asked 15/6, 2021 at 10:18

7

Solved

I'm pretty new in WPF programming environment. I'm trying to write a program out using MVVM design pattern. I've did some studies and read up some articles related to it and many of a time I came ...
Papal asked 22/3, 2016 at 8:53

3

Solved

I'm working on a trading app. I need to list the user stocks and their value (profit or loss) among with the total value of the portfolio. For the holdings list, in an MVP architecture I would crea...

4

I have enabled databinding, but while I execute the code I get this error. error e: [kapt] An exception occurred: android.databinding.tool.util.LoggedErrorException: Found data binding errors. I...
Intangible asked 6/11, 2018 at 6:39

5

In a Multi-layer project with Domain layer (DL)/Business (Service) Layer (BL)/Presentation Layer (PL), what is the best approach to deliver Entities to the Presentation Layer? DO => Domain Obje...
Stoa asked 13/10, 2012 at 15:3

3

Solved

I am using hilt and I am trying to import my SessionManager into my AuthViewModel class. When I am taking a look at Google's documentation on hilt with ViewModel. We can see they are able to inject...
Backchat asked 30/11, 2020 at 0:59

4

Solved

I wondered if it's possible to pass a String data which has declared in Activity class and pass the String data to ViewModel class then pass the data to Fragment class. ViewModel Class class TimeTa...
Blacktail asked 27/3, 2020 at 11:53

10

Solved

I want to initialize ViewModel in Activity using androidx library I have tried what documentation says but it is not working. the ".of" is not resolved. import androidx.appcompat.app.AppCompatAct...

12

Solved

I am trying to implement ViewModel in a 100% Kotlin app. Every piece of documentation I can find says I want to use this to get the ViewModel instance: ViewModelProviders.of(this).get(CustomViewMo...
Inocenciainoculable asked 20/4, 2018 at 5:34

0

As far as I can tell when using Jetpack Compose with Hilt there are two ways of creating/accessing a viewModel instance; viewModel() and hiltViewModel(). I can't understand which should be used as ...

© 2022 - 2024 — McMap. All rights reserved.