Interface: ReactivityHooks

index.ReactivityHooks

Global or scoped lifecycle hooks for reactive telemetry, profiling, and DevTools inspection.

Example

import { registerReactivityHooks } from '@banksia/signals';

const unregister = registerReactivityHooks({
  onTrack(source, consumer) {
    console.log(`[Track] ${consumer.name} -> ${source.meta.label}`);
  },
  onNotify(source, change) {
    console.log(`[Notify] ${source.meta.label}:`, change.oldValue, '->', change.newValue);
  },
});

Table of contents

Methods

Methods

onBatch

Optional onBatch(stats): void

Invoked during batch lifecycle events (start, flush, end).

Parameters

Name Type Description
stats BatchStats Batch phase and count statistics.

Returns

void


onError

Optional onError(error, context): void

Invoked whenever an uncaught error occurs during reactive execution or hook dispatch.

Parameters

Name Type Description
error unknown The error thrown.
context Object Contextual information indicating the source, consumer, and phase of failure.
context.consumer? ReactiveConsumer -
context.phase string -
context.source? ReactiveSource<unknown> -

Returns

void


onExecute

Optional onExecute(consumer, context): void

Invoked immediately before (start) and after (end) a consumer executes.

Parameters

Name Type Description
consumer ReactiveConsumer The consumer subscriber being executed.
context ExecutionContext Execution phase, duration in milliseconds, and any caught error.

Returns

void


onNotify

Optional onNotify(source, change): void

Invoked when a reactive source mutates and invalidates its downstream subscribers.

Parameters

Name Type Description
source ReactiveSource<unknown> The reactive source node that changed.
change ChangeEvent<unknown> Mutation details including old value, new value, and timestamp.

Returns

void


onSchedule

Optional onSchedule(consumer): void

Invoked when the scheduler queues a consumer subscriber for deferred execution.

Parameters

Name Type Description
consumer ReactiveConsumer The consumer subscriber queued for notification.

Returns

void


onTrack

Optional onTrack(source, consumer): void

Invoked when a consumer establishes a dependency edge by reading a reactive source.

Parameters

Name Type Description
source ReactiveSource<unknown> The reactive source node being read.
consumer ReactiveConsumer The active consumer subscriber establishing the dependency.

Returns

void