Search
Loading...
Skip to content

Function: _createReactiveProperty

function _createReactiveProperty<T>(initialValue, options?): _ReactiveProperty<T>;

Creates a reactive property with subscribe, value, and update methods.

This is the main utility for managing state with change notifications. Values are memoized by default (only emit when value changes).

Type Parameters#

Type Parameter
T

Parameters#

ParameterTypeDescription
initialValueTThe initial value of the property
options?_ReactivePropertyOptions<T>Configuration options

Returns#

_ReactiveProperty<T>

A reactive property with subscribe, value, and update methods

Example#

// Simple value
const zoom = createReactiveProperty(1.0);
zoom.subscribe((value) => console.log('Zoom:', value));
zoom.update(2.0); // Logs: "Zoom: 2.0"
// With custom equality for objects
const settings = createReactiveProperty(
{ width: 800, height: 600 },
{ equals: isEqual }
);
// With initial value emission
const formats = createReactiveProperty(
defaultFormats,
{ emitOnSubscribe: true }
);