onTime<T, S> function

Stream<S> Function(Stream<T> stream, OnDataTransform<T, S> , OnDataTransform<S, S> ) onTime <T, S>(
  1. Duration duration

Higher order function implementation for _OnStreamSampler which matches the method signature of buffer and window.

Each item is a sequence containing the items from the source sequence, sampled on a time frame with duration.


Stream<S> Function(
  Stream<T> stream,
  OnDataTransform<T, S>,
  OnDataTransform<S, S>,
) onTime<T, S>(Duration duration) {
  return (
    Stream<T> stream,
    OnDataTransform<T, S> bufferHandler,
    OnDataTransform<S, S> scheduleHandler,
  ) {
    if (duration == null) {
      throw new ArgumentError('duration cannot be null');

    return new _OnStreamSampler<T, S, Null>(
      new Stream<Null>.periodic(duration),