Documentation
API
DerivedField

Derived field

Derived Fields are constructs that calculate their values from other fields or slices.

Example

// Initialize a derived field that depends on counterField
const doubleCounterField = key.derive((state) => {
  return counterField.get(state) * 2;
});

Also read Key.derive or Fields guide.

.get()

Returns the current value of the derived field in a StoreState.

Signature:

field.get(storeState: StoreState): FieldValue

Arguments:

Example:

const doubleCounterField = key.derive((state) => {
  return counterField.get(state) * 2;
});
 
key.effect((store) => {
    doubleCounterField.get(store.state); // 0
})