listenable property

JoltValueListenable<T> get listenable

Converts this Jolt value to a Flutter ValueListenable.

Returns a cached instance that stays synchronized with this Jolt value. Multiple calls return the same instance.

Example:

final signal = Signal(42);
final listenable = signal.listenable;

// Use with ValueListenableBuilder
ValueListenableBuilder<int>(
  valueListenable: listenable,
  builder: (context, value, child) => Text('$value'),
)

Implementation

JoltValueListenable<T> get listenable {
  JoltValueListenable<T>? notifier =
      _notifiers[this] as JoltValueListenable<T>?;
  if (notifier == null) {
    _notifiers[this] = notifier = JoltValueListenable(this);
  }
  return notifier;
}