-
Notifications
You must be signed in to change notification settings - Fork 0
State Management
State is a term that often comes up in front-end development. In essence, state is just how something is at any point in time.
In the case of UI Components that tends to be directly related to whatever data is being rendered or operated on by that Component.
When we talk about state in a front-end application we're usually referring to the data that drives these UI Components, and thus the shape of that data (or in C# land, the type) is part of an applications state.
State data can be used by or operated on by multiple Components, or just one. With so many interactions it becomes necessary to manage access to the state data, in order to reduce bugs and maintanence overhead.
In Ignitor, State refers to a collection of Data Scopes (referred to as just Scopes) that exist with a Context.
A Context is simply the root of a collection of hierarchical Scopes. The default Context is the called the Global Application Scope (GAS).
A Scope is in essence a Dictionary of Immutable data, based on a defined key (or Id). In other words we create Scopes based on an Id Type and a Data Type.
Scopes provide methods from reading, initial loading and updating of their data in a controlled fashion.
Each Context is independent from each other, and be used to separate Scopes based on application function or requirement.
Each Scope is dependent on either its parent Scope or the root Context it was created in.
Note that although Scopes have parent - child relationships, they have no implicit data connection. Modifying data in a Scope will not have any impact on its children. The Scopes simply create an organisational structure. It's up to your application to deal with actual data dependencies.
That said, if you dispose of a Scope, all the data in that Scope is removed as well as all the data within the child Scopes of that Scope.
