Interface SignalOptions<T>

An object that stores the options of the signal to be created.

interface SignalOptions<T> {
    equal?: ((value, prevValue?) => unknown);
    name?: string;
    onActivate?: ((value) => void);
    onCreate?: ((value?) => void);
    onDeactivate?: ((value) => void);
    onException?: ((e, prevValue?) => void);
    onUpdate?: ((value, prevValue?) => void);
}

Type Parameters

  • T

Properties

equal?: ((value, prevValue?) => unknown)

An equality function used to check whether the value of the signal has been changed. Default is Object.is.

Type declaration

    • (value, prevValue?): unknown
    • An equality function used to check whether the value of the signal has been changed. Default is Object.is.

      Parameters

      • value: T

        A new value of the signal.

      • Optional prevValue: T

        A previous value of the signal.

      Returns unknown

      Truthy if the values are equal, falsy otherwise.

Param: value

A new value of the signal.

Param: prevValue

A previous value of the signal.

Returns

Truthy if the values are equal, falsy otherwise.

name?: string

A name of the signal. Can be accessed inside a lifecycle function via this.

onActivate?: ((value) => void)

A function called when the first subscriber or the first active dependent signal appears.

Type declaration

    • (value): void
    • A function called when the first subscriber or the first active dependent signal appears.

      Parameters

      • value: T

        A current value of the signal.

      Returns void

Param: value

A current value of the signal.

onCreate?: ((value?) => void)

A function called at the moment the signal is created.

Type declaration

    • (value?): void
    • A function called at the moment the signal is created.

      Parameters

      • Optional value: T

        An initial value of the signal.

      Returns void

Param: value

An initial value of the signal.

onDeactivate?: ((value) => void)

A function called when the last subscriber or the last active dependent signal disappears.

Type declaration

    • (value): void
    • A function called when the last subscriber or the last active dependent signal disappears.

      Parameters

      • value: T

        A current value of the signal.

      Returns void

Param: value

A current value of the signal.

onException?: ((e, prevValue?) => void)

A function called whenever an unhandled exception occurs during the calculation of the signal value.

Type declaration

    • (e, prevValue?): void
    • A function called whenever an unhandled exception occurs during the calculation of the signal value.

      Parameters

      • e: unknown

        An exception.

      • Optional prevValue: T

        A previous value of the signal.

      Returns void

Param: e

An exception.

Param: prevValue

A previous value of the signal.

onUpdate?: ((value, prevValue?) => void)

A function called each time the signal value is updated.

Type declaration

    • (value, prevValue?): void
    • A function called each time the signal value is updated.

      Parameters

      • value: T

        A new value of the signal.

      • Optional prevValue: T

        A previous value of the signal.

      Returns void

Param: value

A new value of the signal.

Param: prevValue

A previous value of the signal.

Generated using TypeDoc