Interface: ModelOptions<TProps, FS, TS>
Model options.
Type Parameters
| Type Parameter |
|---|
TProps extends ModelProps |
FS |
TS |
Properties
fromSnapshotProcessor?
optional fromSnapshotProcessor?: (sn) => Flatten<{ [k in string | number | symbol]?: IsNeverType<ModelPropFromSnapshotOverride<TProps[k]>, SnapshotInOf<ModelPropStoredCreationValue<(...)[(...)]>>, ModelPropFromSnapshotOverride<TProps[k]>> extends R ? R : never } & { [k in any]: IsNeverType<ModelPropFromSnapshotOverride<TProps[k]>, SnapshotInOf<ModelPropStoredCreationValue<TProps[k]>>, ModelPropFromSnapshotOverride<TProps[k]>> extends R ? R : never }>;
Optional transformation that will be run when converting from a snapshot to the data part of the model. Useful for example to do versioning and keep the data part up to date with the latest version of the model. Snapshot processors must be pure and deterministic. The model's canonical output snapshot must round-trip through this processor to the same model data. Reconciliation may skip invoking it when the input already equals the model's current canonical output snapshot.
Parameters
| Parameter | Type | Description |
|---|---|---|
sn | FS | The custom input snapshot. |
Returns
Flatten<{ [k in string | number | symbol]?: IsNeverType<ModelPropFromSnapshotOverride<TProps[k]>, SnapshotInOf<ModelPropStoredCreationValue<(...)[(...)]>>, ModelPropFromSnapshotOverride<TProps[k]>> extends R ? R : never } & { [k in any]: IsNeverType<ModelPropFromSnapshotOverride<TProps[k]>, SnapshotInOf<ModelPropStoredCreationValue<TProps[k]>>, ModelPropFromSnapshotOverride<TProps[k]>> extends R ? R : never }>
An input snapshot that must match the expected model input snapshot.
toSnapshotProcessor?
optional toSnapshotProcessor?: (sn, modelInstance) => TS;
Optional transformation that will be run when converting the data part of the model into a snapshot. Snapshot processors must be pure and deterministic, and their canonical output must round-trip through the corresponding input processor to the same model data. Snapshot generation may cache processor results.
Parameters
| Parameter | Type | Description |
|---|---|---|
sn | Flatten<{ [k in string | number | symbol]: IsNeverType<TProps[k]["$toSnapshotOverride"], SnapshotOutOf<ModelPropStoredValue<TProps[k]>>, TProps[k]["$toSnapshotOverride"]> extends R ? R : never }> | The output snapshot. |
modelInstance | any | The model instance. |
Returns
TS
a custom output snapshot.
valueType?
optional valueType?: boolean;
A value type will be cloned automatically when being attached to a new tree.
The default is false.