Feature: Pre-registration/optional flattening of required NodeState configurations #7260
Labels
core
Reconciler, DOM, Selection, Node, Events, Composition
enhancement
Improvement over existing feature
Description
The initial version of NodeState implemented in #7117 only offers ad-hoc state for nodes, this means that when a node is deserialized from JSON it does not assign any meaning to that value until it is first read with
$getState
.For many custom nodes going forward, it is expected that most of the node's internal state (beyond the base class) will be represented with NodeState as it requires much less boilerplate and can even be more efficient than implementing it by hand. It makes sense for the nodes to be able to declare in advance what state they require so that full serialization and other features can be enabled prior to instantiation (pre-registration).
NodeState by default serializes everything into a nested object in the serialized node JSON, but for efficiency and backwards/forwards compatibility reasons (refactoring the implementation of a class from __properties to NodeState) it may make sense to lift specifically configured keys to the root of the serialized node JSON.
Impact
This is basically a prerequisite for #7259, but it is also the last remaining piece to make NodeState first class and on par with implementing __properties directly. What I would not like to see is for people to manually write some boilerplate code to implement this flattening on a one-off case when it can be a built-in feature with simple configuration.
The text was updated successfully, but these errors were encountered: