window_with_time 0.1.0 copy "window_with_time: ^0.1.0" to clipboard
window_with_time: ^0.1.0 copied to clipboard

Dart 1 only

A stream transformer for creating windowed streams based on time from a stream

Window With Time #

A stream transformer for creating windowed streams based on time from a stream

Example #

import 'dart:async';
import 'package:window_with_time/window_with_time.dart';

main() {
  var controller  = new StreamController();
  var ids         = 0;
  var counter     = 0;
  var oneSecond   = new Duration(seconds: 1);
  var twoSeconds  = new Duration(seconds: 2);
  var transformer = new WindowWithTime(twoSeconds, oneSecond);
  var windows     = controller.stream.transform(transformer);
  var loop        = new Timer.periodic(oneSecond, (_) {
    controller.add(++counter);
  });

  windows.listen((stream) {
    var id = ++ids;
    stream.listen((data) {
      print("$id => $data");
    });
  });

}
0
likes
25
pub points
0%
popularity

Publisher

unverified uploader

A stream transformer for creating windowed streams based on time from a stream

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

More

Packages that depend on window_with_time