UI abstractions, part 1: MVP
published 2023-08-25
MVP
The model-view-Presenter pattern in short:
Rendering graph...
Premises:
- the model is basically the ‘state container’ holding all relevant data without logic for mutating it
- the model is observable, allowing ‘subscribers’ to register, by basically saying ‘hey, notify me in case some information in that model changed’
The model:
- has it’s state be manipulated by the presenter
- notifies the presenter about state changes
The view:
- is interactive by
- displaying interactive elements for triggering manipulations of the model
- translating UI-events by then invoking methods offered by the presenter
- is rendering the model state by
- having dedicated UI elements displaying aspects of the model state
- being updated by the presenter on change of the underlying model
The presenter:
- provides functions for updating the model, which are invoked by the view