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.

A view model or viewpoints framework in systems engineering, software engineering, and enterprise engineering is a framework which defines a coherent set of views to be used in the construction of a system architecture, software architecture, or enterprise architecture. A view is a representation of a whole system from the perspective of a related set of concerns.

Source: http://en.wikipedia.org/wiki/View_model

4827 questions
1
vote
1 answer

What is a good pattern for updating a viewmodel, both from user interaction and service events?

Consider these two scenarios: a user presses a button in a view (e.g. Fulfill Order) and we want the view to update immediately (disable the button, add a progress bar, etc.) a service layer raises a business event, which ultimately must be…
Kit
  • 20,354
  • 4
  • 60
  • 103
1
vote
2 answers

how to communicate between ViewModels

I have a TabControl with TabPage1 and TabPage2, In TabPage1, there is another TabControl1 with 2 Items TabPage11 and TabPage12. In TabPage2, there is another TabControl2 with 2 Items TabPage21 and TabPage22. Each item (TabPage11 , TabPage12,…
Southsouth
  • 2,659
  • 6
  • 32
  • 39
1
vote
1 answer

Activity/Fragment and ViewModel in Adapter good practice?

Let's assume that we have Activity/Fragment which contains a RecyclerView. Furthermore, it sets an Adapter. For the sake of the example, let's say the Adapter has to have access to Fragment in order to call a method which displays a Snackbar.…
radus14
  • 140
  • 2
  • 8
1
vote
1 answer

in DDD ,how viewmodel can reuse domain model behavior?

I am not sure but as long i read about ddd, domain model should never leave the application layer.. if that is true then how viewmodels can reuse behavior of domain model? Assume the following invoice model in ddd perspective public class…
Stelios
  • 330
  • 5
  • 21
1
vote
0 answers

WinForms databinding with a view model - slow to display view model changes

I have the following configuration... Single form with approximately 50-60 controls (it's a lot, I know) and a single view model which is responsible for storing the state of the form. The view model properties are bound to the editable controls on…
BrentF
  • 41
  • 1
  • 3
1
vote
3 answers

Observing variable in viewmodel is not working

I have this code in which I am trying to observe a variable from my viewmodel. However, whenever I observe the variable, it always returns false, which is the default value, even though it should be returning true. I don't understand why it's not…
dazai
  • 766
  • 4
  • 25
1
vote
2 answers

How to use the keyword also in kotlin android

Am learning android kotlin follow this: https://developer.android.com/topic/libraries/architecture/viewmodel#kotlin class MyViewModel : ViewModel() { private val users: MutableLiveData> by lazy { MutableLiveData>().also { …
Matrix
  • 503
  • 3
  • 17
1
vote
2 answers

Swift, fetching data in viewmodel and passing it to view

I'm trying to update data in my viewModel here is my viewModel; import SwiftUI import CoreLocation final class LocationViewViewModel: ObservableObject { static let previewWeather: Response = load("Weather.json") let weatherManager =…
1
vote
0 answers

Pressed on Back Button destroys ViewModel when using Koin and BottomNavigationView

I'm using architecture-components-samples to learn how multiple back stacks work. Initially, the example works well. I'm interested in the Leaderboard tab, which contains a list of users. In this example, I added Koin and created a…
Tomas
  • 1,567
  • 3
  • 21
  • 38
1
vote
1 answer

Share MainActivity ViewModel between Compose Screens

I am working with JetpackCompose and I have a lifecycle Observable BatteryBroadcast class which is Injected in MainActivity using Hilt and I want to pass data from BatteryBroadcast to the ViewModel to use that data in Composable Screens. So how can…
1
vote
0 answers

MediatR - event handling inside ViewModel - Xamarin

is there any way to handle events from mediator inside the ViewModel. If VM implemetns interface INotification it must be singleton or creates/destroy based on mediators rules. Or how to solve this issue. For example: when i create new Customer(),…
1
vote
0 answers

get Variable from running Task and display on View

The code below executes fine when MyActionFunc is called but not when the function is in another class. MessageBox displays the correct string but it is not shown on view. What I am missing? class ViewModel : INotifyPropertyChanged { public…
Mat52
  • 21
  • 2
1
vote
2 answers

Cannot create an instance of viewmodel class with hilt

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 parameters from viewmodel class to my main activity…
Coding125
  • 21
  • 3
1
vote
1 answer

Multiple view models when sharing data between fragments?

I have an activity with three fragments. All three fragments share a few pieces of data, but they each also have some data that is unique to their respective fragment. I know it is common practice to use shared viewModels as referenced in the Google…
yambo
  • 1,388
  • 1
  • 15
  • 34
1
vote
1 answer

Flutter DropDownButton won't display selected value even when I update it

So I created my own widget that uses the DropDownButton class and it used to work, it would update in a way where after you select a value, it would display the selected value. I refactored my code to involve the whole model-view/viewmodel technique…