@@ -1479,24 +1479,31 @@ abstract class Stream<T> {
14791479
14801480 /// Creates a new stream with the same events as this stream.
14811481 ///
1482- /// Whenever more than [timeLimit] passes between two events from this stream,
1483- /// the [onTimeout] function is called, which can emit further events on
1482+ /// When someone is listening on the returned stream and more than
1483+ /// [timeLimit] passes without any event being emitted by this stream,
1484+ /// the [onTimeout] function is called, which can then emit further events on
14841485 /// the returned stream.
14851486 ///
1486- /// The countdown doesn't start until the returned stream is listened to.
1487- /// The countdown is reset every time an event is forwarded from this stream,
1488- /// or when this stream is paused and resumed.
1487+ /// The countdown starts when the returned stream is listened to,
1488+ /// and is restarted when an event from the this stream is emitted,
1489+ /// or when listening on the returned stream is paused and resumed.
1490+ /// The countdown is stopped when listening on the returned stream is
1491+ /// paused or cancelled.
1492+ /// No new countdown is started when a countdown completes
1493+ /// and the [onTimeout] function is called, even if events are emitted.
1494+ /// If the delay between events of this stream is multiple times
1495+ /// [timeLimit] , at most one timeout will happen between events.
14891496 ///
14901497 /// The [onTimeout] function is called with one argument: an
14911498 /// [EventSink] that allows putting events into the returned stream.
14921499 /// This `EventSink` is only valid during the call to [onTimeout] .
14931500 /// Calling [EventSink.close] on the sink passed to [onTimeout] closes the
14941501 /// returned stream, and no further events are processed.
14951502 ///
1496- /// If [onTimeout] is omitted, a timeout will just put a [TimeoutException]
1503+ /// If [onTimeout] is omitted, a timeout will emit a [TimeoutException]
14971504 /// into the error channel of the returned stream.
1498- /// If the call to [onTimeout] throws, the error is emitted on the returned
1499- /// stream.
1505+ /// If the call to [onTimeout] throws, the error is emitted as an error
1506+ /// on the returned stream.
15001507 ///
15011508 /// The returned stream is a broadcast stream if this stream is.
15021509 /// If a broadcast stream is listened to more than once, each subscription
@@ -1519,8 +1526,6 @@ abstract class Stream<T> {
15191526 new TimeoutException ("No stream event" , timeLimit), null );
15201527 };
15211528 } else {
1522- // TODO(floitsch): the return type should be 'void', and the type
1523- // should be inferred.
15241529 var registeredOnTimeout =
15251530 zone.registerUnaryCallback <void , EventSink <T >>(onTimeout);
15261531 var wrapper = new _ControllerEventSinkWrapper <T >(null );
0 commit comments