watch method

Widget watch(
  1. Widget builder(
    1. T value
    )
)

Creates a widget that rebuilds when this value changes.

The widget automatically tracks this Readable value and rebuilds whenever it changes.

Parameters:

  • builder: Function that builds a widget from the current value

Returns: A widget that rebuilds when this value changes

Example:

final counter = Signal(0);

Column(
  children: [
    counter.watch((value) => Text('Count: $value')),
    ElevatedButton(
      onPressed: () => counter.value++,
      child: Text('Increment'),
    ),
  ],
)

Implementation

Widget watch(Widget Function(T value) builder) {
  return JoltWatchBuilder<T>.value(readable: this, builder: builder);
}