simpleComponent
simpleComponent<
T>(name,schema,options?):ComponentDef<T>
Defined in: src/component-store.ts:513
Build a ComponentDef from a flat schema of primitives.
For a component type T whose every field is a number, boolean, or
string, this helper generates serialize (shallow copy of the declared
fields) and deserialize (per-field as* validation). Extra fields
present on runtime values are ignored by the generated serialize;
extra fields present on raw saves are ignored by deserialize.
For components with nested objects, arrays, enum narrowing, or other shaped data, write the ComponentDef by hand instead.
Type Parameters
Section titled “Type Parameters”T extends { [K in string | number | symbol]: string | number | boolean }
Parameters
Section titled “Parameters”string
schema
Section titled “schema”SimpleSchema<T>
options?
Section titled “options?”Returns
Section titled “Returns”ComponentDef<T>
Example
Section titled “Example”interface Position { x: number; y: number }const PositionDef = simpleComponent<Position>('position', { x: 'number', y: 'number' });