rxdart 0.6.2+1

  • Readme
  • Changelog
  • Installing
  • --

rxdart #

Build Status Coverage Status Pub Gitter

Update This library no longer depends on RxJs and JS interop, instead it now aims to provide a native Dart implementation of Rx, allowing usage of this library in server side (or Flutter) projects as well.

Currently supported

 /// Use the observable method to wrap a Dart stream and add Rx operators to it
 Observable oStream = observable(myStream);
 /// Below operators are now available, next to the original Stream ones (map, where, ...)
 /// the following are contructors
 new Observable
    .combineLatest (deprecated - see below)
    .zip (deprecated - see below)
 /// To better support strong mode, combineLatest and zip
 /// have now been pulled apart into fixed-length constructors.
 /// These methods are available as static methods, since class
 /// factory methods don't support generic method types.
 /// BehaviourSubject and ReplaySubject are available
 /// The default StreamController functions as a PublishSubject
 /// On listen, receive the last added event
 StreamController controllerA = new BehaviourSubject();
 /// On listen, receive all past events
 StreamController controllerB = new ReplaySubject();


void main() {
  var codes = <int>[
      38, // up
      38, // up
      40, // down
      40, // down
      37, // left
      39, // right
      37, // left
      39, // right
      66, // b
      65  // a
  var result = querySelector('#result');
  var controller = new StreamController<KeyboardEvent>();
  var stream = rx.observable(controller.stream);

  document.addEventListener('keyup', (event) => controller.add(event));

    .map((event) => event.keyCode )           // get the key code
    .bufferWithCount(10, 1)                   // get the last 10 keys
    .where((list) => _areTwoListsEqual(list, codes))
    .listen((_) => result.innerHtml = 'KONAMI!');

bool _areTwoListsEqual(List<int> a, List<int> b) {
  for (int i=0; i<10; i++) if (a[i] != b[i]) return false;
  return true;

0.6.2 #

  • Added just (thanks to brianegan)
  • Added groupBy
  • Added amb

0.6.1 #

  • Added concat

0.6.0 #

  • BREAKING: startWith now takes just one parameter instead of an Iterable. To add multiple starting events, please use startWithMany.
  • Added BehaviourSubject and ReplaySubject. These implement StreamController.
  • BehaviourSubject will notify the last added event upon listening.
  • ReplaySubject will notify all past events upon listening.
  • DEPRECATED: zip and combineLatest, use their strong-type-friendly alternatives instead (available as static methods on the Observable class, i.e. Observable.combineThreeLatest, Observable.zipFour, ...)

0.5.1 #

  • Added documentation (thanks to dustinlessard-wf)
  • Fix tests breaking due to deprecation of expectAsync
  • Fix tests to satisfy strong mode requirements

0.5.0 #

  • As of this version, rxdart depends on SDK v1.21.0, to support the newly added generic method type syntax

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  rxdart: ^0.6.2+1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:rxdart/rxdart.dart';
Awaiting analysis to complete.