useStream<T> function

Stream<T> useStream<T>(
  1. ReadonlyNode<T> value
)

Creates a stream hook from a reactive value.

Converts a reactive value into a Dart stream, allowing you to use reactive values with stream-based APIs like StreamBuilder.

Parameters:

  • value: The reactive value to convert to a stream

Returns: A Stream that emits values when the reactive value changes

Example:

setup(context, props) {
  final count = useSignal(0);
  final stream = useStream(count);

  return () => StreamBuilder<int>(
    stream: stream,
    builder: (context, snapshot) {
      return Text('Count: ${snapshot.data ?? 0}');
    },
  );
}

Implementation

Stream<T> useStream<T>(ReadonlyNode<T> value) {
  return useMemoized(() => value.stream);
}