Here we use a simple scenario to explain how MVVM works in ZK. Assume that a user click a button then "Hello World" text appears. The flow is as follows: As stated in the paragraph earlier, the binder synchronizes data between UI and ViewModel.
- A user presses a button on the screen (perform an action).
- A corresponding event is fired to the binder.
- The binder finds the corresponding action logic (It is Command) in the ViewModel and executes it.
- The action logic accesses data from Model layer and updates ViewModel's corresponding properties.
- ViewModel notify the binder that some properties have been changed.
- Per what properties have been changed, the binder loads data from the ViewModel.
- Binder then updates the corresponding UI components to provide visual feedback to the user.