Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Copy paste from the included TS doc:
Similarly to regular [[Store]] the
DerivedStore
allows you to observe and modify a state.Unlike with the [[Store]], the state is not stored within a
DerivedStore
, but it is derived from a source store.The way how the state is derived is defined by the
selector
parameter of the constructor.Every
update
instruction is translated to an update instruction on the source store - meaning that changes on the derived state are propagated to the source state. This merging of source state and a new derived state is handled through themerger
parameter of the constructor.Example:
The usage is not limited to a property access. You can use it to access array elements or deep path within an object.
Furthermore the
DerivedStore
can be sub-classed and enhanced with selectors (this.pipe()
) and update methods.