LogoSignals.dart
Copy Markdown
rodydavis/signals.dart 999999

SignalsObserver

You can observe all signal values in the dart application by providing an implementation of <code>SignalsObserver</code>:.

You can observe all signal values in the dart application by providing an implementation of SignalsObserver:

abstract class SignalsObserver {
  void onSignalCreated(Signal instance);
  void onSignalUpdated(Signal instance, dynamic value);
  void onComputedCreated(Computed instance);
  void onComputedUpdated(Computed instance, dynamic value);
  static SignalsObserver? instance;
}

There is a prebuilt LoggingSignalsObserver for printing updates to the console.

To add the observer override the instance at the start of the application:

void main() {
    SignalsObserver.instance = LoggingSignalsObserver(); // or custom observer
    ...
}

This will have a slight performance hit since every update will be tracked via the observer. It is recommended to only set the SignalsObserver.instance in debug or profile mode.

Properties#

View Properties
static SignalsObserver? instance

The current observer instance.

Methods#

View Methods
void onSignalCreated(Signal instance, T value)

Called when a signal is created.

void onSignalUpdated(Signal instance, T value)

Called when a signal is updated.

void onComputedCreated(Computed instance)

Called when a computed is created.

void onComputedUpdated(Computed instance, T value)

Called when a computed is updated.

void onEffectCreated(Effect instance)

Called when a effect is created.

void onEffectCalled(Effect instance)

Called when a effect is called.

void onEffectRemoved(Effect instance)

Called when a effect is disposed.


LoggingSignalsObserver#

Logs all signals and computed changes to the console.

Methods#

View Methods
void onComputedCreated(Computed instance)
void onComputedUpdated(Computed instance, T value)
void onSignalCreated(Signal instance, T value)
void onSignalUpdated(Signal instance, T value)
void onEffectCreated(Effect instance)
void onEffectCalled(Effect instance)
void onEffectRemoved(Effect instance)
void log(String message)

Logs a message to the console.


onSignalRead#

Global callback when any signal is read.


signalsDevToolsEnabled#

Manually enable/disable signals devtools


DevToolsSignalsObserver#

Signals DevTools observer

Constructors#

View Constructors
DevToolsSignalsObserver()

Create a DevToolsSignalsObserver and register the VM service extensions.

Methods#

View Methods
bool enabled

Check if devTools is enabled

enabled(bool value)

Enable/Disable devTools

void reassemble()

Reload the signals devTools

void onComputedCreated(Computed instance)
void onComputedUpdated(Computed instance, T value)
void onSignalCreated(Signal instance, T value)
void onSignalUpdated(Signal instance, T value)
void log(String message)

Logs a message to the console.

void onEffectCreated(Effect instance)
void onEffectCalled(Effect instance)
void onEffectRemoved(Effect instance)
Map<String, dynamic> getNodes()

Returns a map representation of all active signals, computeds, and effects in the reactive graph.


disableSignalsDevTools#

Disable the devtools


reloadSignalsDevTools#

Reload the devtools