Skip to content

Function: useNumber()

useNumber(device, name, element): number | undefined

Subscribe to one numeric value.

useElement hands back the element union, so reading .value off it does not narrow (a BLOB element has data, not value). These four hooks are the "I know what kind this is" shortcut, and return the value itself:

const azimuth = useNumber("Dome Simulator", "ABS_DOME_POSITION", "DOME_ABSOLUTE_POSITION");
return <h1>{azimuth ?? "--"}°</h1>;

Parameters

device

string

The device name.

name

string

The property name.

element

string

The element name.

Returns

number | undefined

The value, or undefined if the property is not defined yet or that element is of another kind.