On This Page
ViewModel lifecycle
For each request, Mateu follows this lifecycle:
- determine the target ViewModel type
- instantiate and hydrate the ViewModel
- resolve menu / route if needed
- obtain the final ViewModel
- execute the requested method or action
- serialize the result and send it to the frontend
Practical implications
Hydration first
Route parameters and query parameters are injected before any UI logic is evaluated.
Fluent components
Fields of type Component are evaluated against the already hydrated ViewModel.
Fields of type Callable<?> are also evaluated after hydration, which makes them suitable for dynamic UI.
Actions
Actions can:
- mutate the ViewModel state
- return UI effects such as
MessageorUICommand
Both things happen in the same request.
👉 See Execution model →