resolveBool

Reads a boolean attribute that may be a condition, such as hidden: t > 3, at the current parameter values, or returns fallback.

@internote/canvas-sdkFunction
On this page
import { resolveBool } from '@internote/canvas-sdk';

A bool attribute reads its whole text as a condition (D57), so a boolean may arrive as a bound $chalk-expression rather than true or false — whenever it follows a slider's letter or a node's live member. Testing attrs.hidden === true misses every such value; this decides it with the compiler's own rules. fallback is returned for a value that is neither, and for a condition while the runtime has not loaded.

#Signature

(
    value: unknown,
    params?: Record<string, number>,
    fallback?: boolean,
    refs?: (ref: ExpressionRef) => unknown,
): boolean

#Parameters

value
A refined attribute value.
params
The parameter values, such as ctx.parameters.numbers().
fallback
What to return when the value does not come out as a boolean.
refs
The live value of a #id.member the condition reads, where the caller has a store.

#Example

if (resolveBool(attrs.hidden, ctx.parameters.numbers())) return null;

Declared in packages/canvas-sdk/src/data/values.ts:116.

Last updated