react method

void react(
  1. void onData(
    1. T
    ), [
  2. Function? onError
])

If this stream has produced a value or error since the last time the current computation notified its downstream, runs the given functional on the value or error produced by this stream.

If no onError is provided and the stream has produced an error, the current computation will be assumed to have thrown that error at the end if it returns a value. Also subscribes the current computation to all values and errors produced by this stream. As a rule of thumb, you should use react over use if this stream represents a sequence of events rather than a state. Unlike use, react does trigger a re-computation if the stream consecutively produces values comparing equal to each other. Can only be used inside computations. Cannot be used inside react callbacks. If the last item in the stream is an error, throws it. onError has the same semantics as in Future.listen

Implementation

void react(void Function(T) onData, [Function? onError]) =>
    StreamComputedExtensionImpl<T>(this).react(onData, onError);