Skip to main content

Hooks

useDrawing#

Hook to select parts of the drawing state.

Declaration

export function useDrawing<T>(id: DrawingID, sel: (state: DrawingState) => T | undefined, equalityFn?: ((a: T | undefined, b: T | undefined) => boolean) | undefined): T | undefined;

Params

NameTypeDefaultDescription
idDrawingIDThe drawing id.
sel(state: DrawingState) => T l undefinedThe selector of the drawing state.
equalityFn?((a: T l undefined, b: T l undefined) => boolean) l undefinedThe equality function.

Returns T | undefined
The part of the drawing state selected by the selector function (sel). Result can be undefined!

usePlugin#

Hook to select parts of the plugin state.

Declaration

export function usePlugin<T>(drawingId: DrawingID, pluginId: PluginID, sel: (state: PluginState) => T | undefined, equalityFn?: ((a: T | undefined, b: T | undefined) => boolean) | undefined): T | undefined;

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
pluginIdPluginIDThe plugin id.
sel(state: PluginState) => T l undefinedThe selector of the plugin state.
equalityFn?((a: T l undefined, b: T l undefined) => boolean) l undefinedThe equality function.

Returns T | undefined
The part of the plugin state selected by the selector function (sel). Result can be undefined!