buffered_stream 1.0.0
buffered_stream: ^1.0.0 copied to clipboard

A stream implementation that queues all inputs until there is a listener.

A stream implementation that queues all inputs until there is a listener.

Usage #

A simple usage example:

import 'dart:async';

import 'package:buffered_stream/buffered_stream.dart';
import 'dart:io';

void main() async {
  stdin
    ..echoMode = false
    ..lineMode = false;

  var periodicStream = Stream.periodic(Duration(milliseconds: 100), (i) => i);
  var stream = BufferedStream<int>.from(periodicStream);

  StreamSubscription<int>? sub;
  stdin.listen((event) {
    if (event.first == 32) {
      if (sub != null) {
        print('Cancelled!');
        sub!.cancel();
        sub = null;
      } else {
        print('New Stream');
        sub = stream.listen((i) {
          print(i.toString());
        });
      }
    }
  });
}

2
likes
120
pub points
38%
popularity

A stream implementation that queues all inputs until there is a listener.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

More

Packages that depend on buffered_stream