Signal<T>.lazy constructor

Signal<T>.lazy({
  1. String? debugLabel,
  2. bool autoDispose = false,
})

Lazy signal that can be created with type T that the value will be assigned later.

final db = Signal.lazy<DatabaseConnection>();
...
db.value = DatabaseConnect(...);

Implementation

Signal.lazy({
  super.debugLabel,
  super.autoDispose,
})  : _lazy = true,
      super._(globalId: ++_lastGlobalId) {
  assert(() {
    if (!_lazy) SignalsObserver.instance?.onSignalCreated(this);
    return true;
  }());
}