Type alias PartitionableState<Key>

PartitionableState<Key>: object & {
    [k in Key]: RootState
}

An item satisfying type constraints of RootState but where a child item at Key also satisfies RootState. A Store with a PartitionableState can therefore be partitioned into a child Store by Key.

Partitioning enables hierarchy and logical isolation of a Store, so that higher-level stores can be composed of multiple lower-level stores. Logic relying on some Store<T> need not know whether <T> is the whole app state or just some part of it.

Partitioning can also make eventing more efficient. When a parent Store's RootState changes, implementations can omit notifications for all Watchers of a child partition if the child RootState has not changed, meaning no value within the child partition has changed.

See also createStorePartition.

Type Parameters

  • Key extends PropertyKey