I have started learning about Redux and React in the web-world, and the more I learn about it the more I'm realizing how painful state management is in the desktop-world with WPF's MVVM-style architecture (using Caliburn specifically to bind Views to ViewModels).
Redux has a few simple principles that dictate how state should be managed, making UI updates, event handling and state changes much more predictable. The principles are:
- A single source of truth (all mutable state is stored in a single shared object).
- State is read-only. It cannot be modified by components through-out the code, which is typically what happens in WPF.
- State can only be modified by pure functions.
WPF's MVVM architecture allows you to build interactive views very quickly, but debugging issues when various viewmodels and events all change state is a nightmare. For example: an event fired that changed a view and tried to set a default tab, but the data has not finished loading asynchronously from a web service so the tab doesn't exist (yet) so nothing happens
I've spent hours drawing diagrams to try and understand complex interactions between inter-related viewModels components that update one-another.
I understand that Redux aims to solve some of this state unpredictability. Is there something similar, or an architectural pattern that would fit nicely with WPF to help manage state better? I'm not sure how well the Redux principles would work in .NET as I have not tried them yet. Perhaps somebody has some experience that can give some advice?