useJoltStream<T> function

Stream<T> useJoltStream<T>(
  1. Readable<T> value, {
  2. List<Object?>? keys,
})

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
  • keys: Optional keys for hook memoization

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

Example:

Widget build(BuildContext context) {
  final count = useSignal(0);
  final stream = useJoltStream(count);

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

Implementation

Stream<T> useJoltStream<T>(Readable<T> value, {List<Object?>? keys}) {
  final stream = useMemoized(() => value.stream, keys ?? const []);

  return stream;
}