Questions tagged [viewmodel]
A view model or viewpoints framework is a framework which defines a coherent set of views to be used in the construction of an architecture. A view is a representation of a whole system from the perspective of a related set of concerns.
viewmodel
4,956
questions
-1
votes
0
answers
18
views
ViewModel in Android [closed]
Can we have a viewModel in android in a project having more than 200 lines of code or viewModel should have minimum number of lines of code?
I am developing a camera app, in which, user have to take ...
-1
votes
1
answer
24
views
where the creation point of the savedStateHandle[key, value] map?
first, sorry for my bad eng.
https://github.com/google-developer-training/basic-android-kotlin-compose-training-inventory-app/tree/main
using this app and
https://developer.android.com/codelabs/basic-...
0
votes
0
answers
20
views
How do I test view models for Android? I've been struggling with this for over a week
I am trying to test view model classes for my app. They use viewModelScope.launch and when I run tests using Firebase emulator, data will sometimes go to Firebase and sometimes won't resulting in ...
0
votes
0
answers
24
views
LiveData is not updating its value on 2nd api call
I am fetching currency exchange rate by api call using retrofit and ViewModel concept.On launch of application I am able to get the latest data from the server but when I am trying to update the live ...
0
votes
2
answers
75
views
How to Reinitialize Singleton Pages and ViewModels on User Logout and Login in a MAUI Shell App?
Problem Description
I am developing a MAUI app that utilizes Shell tabs alongside a login flow. Each tab’s page and corresponding ViewModel are registered as singletons. Upon the initial load, the ...
0
votes
0
answers
15
views
Need to share data from Main Activity with Fragments managed by NavController
I have a very simple main activity with some state that I need to share with fragments being managed by a DrawerLayout and NavigationView hosted in the main activity layout
Can someone show a simple ...
0
votes
0
answers
18
views
Initialise SavedStateHandle in shared view model
I have a parent fragment and a child fragment which have a shared viewmodel. The viewmodel uses the SavedStateHandle to retain viewmodel state even after process kill. The parent fragment uses shared ...
1
vote
1
answer
46
views
Ui does not recompose upon updating the stateflow from the ViewModel
I can change my view model's internal state by calling redirection(verified with Log statements), but it doesn't have any effect on gUiState in my main composable. Why is that?
The main composable ...
-1
votes
0
answers
32
views
Do I need to avoid custom view inits when using a stateobject which relies on passed information?
I have a multi-staged question.
Scenario: I have a list of user posts, where the list contains only a small subset of information about each post given the size requirement to show a list. Each post ...
0
votes
0
answers
29
views
java.lang.RuntimeException: Unable to start activity ComponentInfo{}: java.lang.reflect.InvocationTargetException
I am trying to use MVVM with Room DB in my android app but getting this exception on the splashActivity.
It was working fine until i added viewmodel and observers
class SplashActivity : ...
1
vote
1
answer
27
views
How to access a viewmodel as a function argument?
Android Studio shows an error:
Unresolved reference: abc
I tried changing the view model name and how it is instantiated, e.g. val myViewModel5 by viewModels<MyViewModel>()
class ...
1
vote
1
answer
35
views
How to pass a string to a view model upon initialization?
I have an iOS app with the following views:
struct LoggedInUserView: View{
@ObservedObject var viewModel: LoggedInUserViewModel
@StateObject var sharedPortionViewModel: SharedPortionViewModel(...
0
votes
1
answer
31
views
What is the difference between UIPickerViewDataSource and UIPickerViewModel on Xamarin
When it comes down to UIPickerView, I've always used a UIPickerViewDataSource to fill my picker view with data. Recently I've found out that there is also an option to use a UIPickerViewModel, but I ...
1
vote
1
answer
68
views
I cannot fetch the data from viewmodel in ASP.NET Core MVC. My values for "input-asp-for" looks null in my view. How can I fix this problem?
First Image Description
Second Image Description
When I go to the view, I see some input asp-for fields as null, even though they aren't null. In ViewModel, the reference from other models are given ...
0
votes
1
answer
28
views
How to send ViewModel event on activity start in the ViewModel init function correctly?
I want a camera screen to open after the activity has been created. When I send an event triggering the camera in the ViewModel init function then nothing happens:
The ViewModel init function:
init{
...