customized_streams 1.0.16 copy "customized_streams: ^1.0.16" to clipboard
customized_streams: ^1.0.16 copied to clipboard

CustomizedStreams is an implementation of the rxdart programming, leveraging the native Dart Streams api for stream transformation.

CustomizedStreams #

About #

CustomizedStreams adds additional capabilities to Dart Streams and StreamControllers.

CustomizedStreams provides a number of additional Subjects that help transfrom type and value of stream.

Usage #

Transform stream from one type to another type #

import 'package:customized_streams/customized_streams.dart';

Stream<int> _transformCountLength(String text) async* {
  yield text.length;
}

void main() {
  var ts =
      TransformerSubject<String, int>(_transformCountLength);
  ts.outputStream.listen((data) {
    print("Length of " +
        ts.inputValue +
        " is " +
        data.toString()); // Print: Length of HelloWorld is 11
  }, onDone: () {
    ts.dispose();
  });
  ts.add("Hello World");
}

Defered stream: new stream will initialized with latest value #

import 'package:customized_streams/customized_streams.dart';

Stream<int> _transformCountLength(String text) async* {
  yield text.length;
}

void main() async {
  var ts = TransformerSubject<String, int>(_transformCountLength);
  var inputStream1 = ts.inputStream;
  inputStream1.listen((data) {
    print(data); // ["Hello", "World", "Developer"]
  });
  ts.add("Hello");
  ts.add("World");
  await Future.delayed(Duration(seconds: 1));
  var inputStream2 = ts.inputStream;
  inputStream2.listen((data) {
    print(data); // ["World", "Developer"]
  }, onDone: () {
    ts.dispose();
  });

  ts.add("Developer");
}

Flutter Example #

Install Flutter

In order to run the flutter example, you must have Flutter installed. For installation instructions, view the online documentation.

Run the app

  1. Open up an Android Emulator, the iOS Simulator, or connect an appropriate mobile device for debugging.
  2. Open up a terminal
  3. cd into the example directory
  4. Run flutter doctor to ensure you have all Flutter dependencies working.
  5. Run flutter packages get
  6. Run flutter run

Changelog #

Refer to the Changelog to get all release notes.

0
likes
40
pub points
0%
popularity

Publisher

verified publishervo9312.co

CustomizedStreams is an implementation of the rxdart programming, leveraging the native Dart Streams api for stream transformation.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

analyzer, rxdart

More

Packages that depend on customized_streams