React API Reference
InterpreterEntityInstance
This interface describes the properties of an interpreter entity instance, which is usually injected as a prop into interpreter entities components.
Reference
InterpreterEntityInstance<TEntity>
import { type InterpreterEntityInstance } from "@coltorapps/builder-react";
import { textFieldEntity } from "./text-field-entity";
type InterpreterTextFieldInstance = InterpreterEntityInstance<
typeof textFieldEntity
>;
Properties
The InterpreterEntityInstance
interfaces has the following properties:
Prop | Type | Description |
---|---|---|
id | string | The unique identifier of the entity. |
type | string | The type identifier of the entity. Corresponds to the key of the entity definition in the builder defintion. |
children | array optional | Optional array of child entity IDs. |
parentId | string optional | Optional ID of the parent entity. If undefined, the entity is considered a root-level entity. |
attributes | object | A record of all attributes values for the entity, keyed by attribute name. |
metadata | unknown | Your custom metadata associated with the entity. |
getValue | function | Returns the current value of the entity, or undefined if no value is set. |
setValue | function | Sets the entity’s value. |
getError | function | Returns the current validation error associated with the entity’s value, if any. |
setError | function | Sets a validation error for the entity’s value. |
resetValue | function | Resets the value of the entity to its initial state. |
clearValue | function | Clears the value of the entity completely. |
resetError | function | Clears the current validation error. |
validate | function | Validates the current value of the entity. Returns a promise that resolves with the validation result. |
subscribeToValue | function | Subscribes to changes in the entity’s value. Returns an unsubscribe function. |
subscribeToError | function | Subscribes to changes in the entity’s error state. Returns an unsubscribe function. |