Viewing version 0.16.6. Open the latest package page.

rxdart

0.16.6

RxDart is an implementation of the popular reactiveX api for asynchronous programming, leveraging the native Dart Streams api.

Download archive

Readme

RxDart

Build Status codecov Pub Gitter

About

RxDart is a reactive functional programming library for Google Dart, based on ReactiveX.
Google Dart comes with a very decent Streams API out-of-the-box; rather than attempting to provide an alternative to this API, RxDart adds functionality on top of it.

Version

Dart 1.0 is supported until release 0.15.x, version 0.16.x is no longer backwards compatible and requires the Dart SDK 2.0

How To Use RxDart

For Example: Reading the Konami Code

void main() {
  const konamiKeyCodes = const <int>[
    KeyCode.UP,
    KeyCode.UP,
    KeyCode.DOWN,
    KeyCode.DOWN,
    KeyCode.LEFT,
    KeyCode.RIGHT,
    KeyCode.LEFT,
    KeyCode.RIGHT,
    KeyCode.B,
    KeyCode.A];

  final result = querySelector('#result');
  final keyUp = new Observable<KeyboardEvent>(document.onKeyUp);

  keyUp
    .map((event) => event.keyCode)
    .bufferCount(10, 1)
    .where((lastTenKeyCodes) => const IterableEquality<int>().equals(lastTenKeyCodes, konamiKeyCodes))
    .listen((_) => result.innerHtml = 'KONAMI!');
}

API Overview

Objects

Observable

RxDart's Observables extends the Stream class. This has two major implications:

Finally, the Observable class & operators are simple wrappers around Stream and StreamTransformer classes. All underlying implementations can be used free of the Observable class, and are exposed in their own libraries. They are linked to below.

Instantiation

Generally speaking, creating a new Observable is either done by wrapping a Dart Stream using the top-level constructor new Observable(), or by calling a factory method on the Observable class. But to better support Dart's strong mode, combineLatest and zip have been pulled apart into fixed-length constructors. These methods are supplied as static methods, since Dart's factory methods don't support generic types.

Usage
var myObservable = new Observable(myStream);

Available Factory Methods

Usage
var myObservable = new Observable.merge([myFirstStream, mySecondStream]);
Available Static Methods
Usage
var myObservable = Observable.combineLatest3(
    myFirstStream, 
    mySecondStream, 
    myThirdStream, 
    (firstData, secondData, thirdData) => print("$firstData $secondData $thirdData"));

Transformations

Available Methods

A full list of all methods and properties including those provided by the Dart Stream API (such as first, asyncMap, etc), can be seen by examining the DartDocs

Usage
var myObservable = new Observable(myStream)
    .bufferCount(5)
    .distinct();

Examples

Web and command-line examples can be found in the example folder.

Web Examples

In order to run the web examples, please follow these steps:

  1. Clone this repo and enter the directory
  2. Run pub get
  3. Run pub serve example/web
  4. Navigate to http://localhost:8080 in your browser

Command Line Examples

In order to run the command line example, please follow these steps:

  1. Clone this repo and enter the directory
  2. Run pub get
  3. Run dart example/bin/fibonacci.dart 10

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/flutter/github_search directory
  4. Run flutter doctor to ensure you have all Flutter dependencies working.
  5. Run flutter packages get
  6. Run flutter run

Notable References

Changelog

Refer to the Changelog to get all release notes.

Changelog

0.16.6

  • Rework for buffer and window, allow to schedule using a sampler
  • added buffer
  • added bufferFuture
  • added bufferTest
  • added bufferTime
  • added bufferWhen
  • added window
  • added windowFuture
  • added windowTest
  • added windowTime
  • added windowWhen
  • added onCount sampler for buffer and window
  • added onFuture sampler for buffer and window
  • added onTest sampler for buffer and window
  • added onTime sampler for buffer and window
  • added onStream sampler for buffer and window

0.16.5

  • Renames amb to race
  • Renames flatMapLatest to switchMap
  • Renames bufferWithCount to bufferCount
  • Renames windowWithCount to windowCount

0.16.4

  • Adds bufferTime transformer.
  • Adds windowTime transformer.

0.16.3

  • Adds delay transformer.

0.16.2

  • Fix added events to sink are not processed correctly by Subjects.

0.16.1

  • Fix dematerialize method for Dart 2.

0.16.0+2

  • Add value to BehaviorSubject. Allows you to get the latest value emitted by the subject if it exists.
  • Add values to ReplayrSubject. Allows you to get the values stored by the subject if any exists.

0.16.0+1

  • Update Changelog

0.16.0

  • breaks backwards compatibility, this release only works with Dart SDK >=2.0.0.
  • Removed old cast in favour of the now native Stream cast method.
  • Override retype to return an Observable.

0.15.1

  • Add exhaustMap map to inner observable, ignore other values until that observable completes.
  • Improved code to be dartdevc compatible.
  • Add upper SDK version limit in pubspec

0.15.0

  • Change debounce to emit the last item of the source stream as soon as the source stream completes.
  • Ensure debounce does not keep open any addition async timers after it has been cancelled.

0.14.0+1

  • Change DoStreamTransformer to return a Future on cancel for api compatibility.

0.14.0

  • Add PublishSubject (thanks to @pauldemarco)
  • Fix bug with doOnX operators where callbacks were fired too often

0.13.1

  • Fix error with FlatMapLatest where it was not properly cancelled in some scenarios
  • Remove additional async methods on Stream handlers unless they're shown to solve a problem

0.13.0

  • Remove call operator / StreamTransformer entirely
  • Important bug fix: Errors thrown within any Stream or Operator will now be properly sent to the StreamSubscription.
  • Improve overall handling of errors throughout the library to ensure they're handled correctly

0.12.0

  • Added doOn* operators in place of call.
  • Added DoStreamTransformer as a replacement for CallStreamTransformer
  • Deprecated call and CallStreamTransformer. Please use the appropriate doOnX operator / transformer.
  • Added distinctUnique. Emits items if they've never been emitted before. Same as to Rx#distinct.

0.11.0

  • !!!Breaking Api Change!!!
    • Observable.groupBy has been removed in order to be compatible with the next version of the Stream class in Dart 1.24.0, which includes this method

0.10.2

  • BugFix: The new Subject implementation no longer causes infinite loops when used with ng2 async pipes.

0.10.1

  • Documentation fixes

0.10.0

  • Api Changes
    • Observable
      • Remove all deprecated methods, including:
        • observable factory -- replaced by the constructor new Observable()
        • combineLatest -- replaced by Strong-Mode versions combineLatest2 - combineLatest9
        • zip -- replaced by Strong-Mode versions zip2 - zip9
      • Support asObservable conversion from Future-returning methods. e.g. new Observable.fromIterable([1, 2]).first.asObservable()
      • Max and Min now return a Future of the Max or Min value, rather than a stream of increasing or decreasing values.
      • Add cast operator
      • Remove ConcatMapStreamTransformer -- functionality is already supported by asyncExpand. Keep the concatMap method as an alias.
    • Subjects
      • BehaviourSubject has been renamed to BehaviorSubject
      • The subjects have been rewritten and include far more testing
      • In keeping with the Rx idea of Subjects, they are broadcast-only
  • Documentation -- extensive documentation has been added to the library with explanations and examples for each Future, Stream & Transformer.
    • Docs detailing the differences between RxDart and raw Observables.

0.9.0

  • Api Changes:
    • Convert all StreamTransformer factories to proper classes
      • Ensure these classes can be re-used multiple times
    • Retry has moved from an operator to a constructor. This is to ensure the stream can be properly re-constructed every time in the correct way.
    • Streams now properly enforce the single-subscription contract
  • Include example Flutter app. To run it, please follow the instructions in the README.

0.8.3+1

  • rename examples map to example

0.8.3

  • added concatWith, zipWith, mergeWith, skipUntil
  • cleanup of the examples folder
  • cleanup of examples code
  • added fibonacci example
  • added search GitHub example

0.8.2+1

  • moved repo into ReactiveX
  • update readme badges accordingly

0.8.2

  • added materialize/dematerialize
  • added range (factory)
  • added timer (factory)
  • added timestamp
  • added concatMap

0.8.1

  • added never constructor
  • added error constructor
  • moved code coverage to codecov.io

0.8.0

  • BREAKING: tap is replaced by call(onData)
  • added call, which can take any combination of the following event methods: onCancel, onData, onDone, onError, onListen, onPause, onResume

0.7.1+1

  • improved the README file

0.7.1

  • added ignoreElements
  • added onErrorResumeNext
  • added onErrorReturn
  • added switchIfEmpty
  • added empty factory constructor

0.7.0

  • BREAKING: rename combineXXXLatest and zipXXX to a numbered equivalent, for example: combineThreeLatest becomes combineLatest3
  • internal refactoring, expose streams/stream transformers as a separate library

0.6.3+4

  • changed ofType to use TypeToken

0.6.3+3

  • added ofType

0.6.3+2

  • added defaultIfEmpty

0.6.3+1

  • changed concat, old concat is now concatEager, new concat behaves as expected

0.6.3

  • Added withLatestFrom
  • Added defer ctr (both thanks to brianegan)

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

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add 'rxdart:0.16.6'
pubspec.yaml
name: rxdart
version: 0.16.6
authors:
- Frank Pepermans <frank@igindo.com>
- Brian Egan <brian@brianegan.com>
description: RxDart is an implementation of the popular reactiveX api for asynchronous programming, leveraging the native Dart Streams api.
homepage: https://github.com/ReactiveX/rxdart
environment:
  sdk: '>=2.0.0-dev <3.0.0'
dev_dependencies:
  browser: ^0.10.0+2
  test: ^0.12.30
  benchmark_harness: ">=1.0.0 <2.0.0"
  coverage: ^0.9.2
  stack_trace: "^1.9.2"
web:
  compiler:
    debug: dartdevc

Version history

VersionPublishedArchiveSHA-256
0.1.0Cached · Upstream SHA-256 matchedDownload7b2c6e72…523c15
0.1.0+1Cached · Upstream SHA-256 matchedDownloadd3b2922d…679f2a
0.1.0+2Cached · Upstream SHA-256 matchedDownloadedfa980c…d43a9b
0.1.0+3Cached · Upstream SHA-256 matchedDownloaddc82051d…0285ab
0.1.0+4Cached · Upstream SHA-256 matchedDownload39c33b63…bb88ce
0.1.0+5Cached · Upstream SHA-256 matchedDownloadb2e90d5e…96e23e
0.1.0+6Cached · Upstream SHA-256 matchedDownloade417d502…bb148e
0.2.0Cached · Upstream SHA-256 matchedDownload4fdc3a49…725854
0.2.0+1Cached · Upstream SHA-256 matchedDownload71d9f48f…f3879d
0.2.0+3Cached · Upstream SHA-256 matchedDownloadb7742d6d…daea85
0.3.0Cached · Upstream SHA-256 matchedDownload7eeca94a…2df1ed
0.3.1Cached · Upstream SHA-256 matchedDownloadfc0a390f…3415e3
0.3.2Cached · Upstream SHA-256 matchedDownload353a7970…100d09
0.3.3Cached · Upstream SHA-256 matchedDownload9276f3f4…23c6d5
0.3.4Cached · Upstream SHA-256 matchedDownload3fa075ce…7b5512
0.3.5Cached · Upstream SHA-256 matchedDownloadc6a63b6f…0bdb0b
0.3.6Cached · Upstream SHA-256 matchedDownload9695e85a…ae84a5
0.3.7Cached · Upstream SHA-256 matchedDownload5eb73e19…e1ba1a
0.3.8Cached · Upstream SHA-256 matchedDownload491112d8…41339d
0.3.8+1Cached · Upstream SHA-256 matchedDownload6e7b0d49…ce7b24
0.3.9Cached · Upstream SHA-256 matchedDownloadf3660828…9c9ecc
0.3.10Cached · Upstream SHA-256 matchedDownloadf2fa34eb…e31b70
0.3.11Cached · Upstream SHA-256 matchedDownloadb5c4093d…f1c0a8
0.3.12Cached · Upstream SHA-256 matchedDownloadefb6bc41…3ec0c3
0.3.13Cached · Upstream SHA-256 matchedDownloadb606e2b9…a97fdd
0.3.14Cached · Upstream SHA-256 matchedDownloaddd3a48de…129a13
0.3.15Cached · Upstream SHA-256 matchedDownload14cac08f…61d366
0.3.16Cached · Upstream SHA-256 matchedDownload45c18814…d6fd01
0.3.17Cached · Upstream SHA-256 matchedDownload472670ab…5b128b
0.3.18Cached · Upstream SHA-256 matchedDownload003af73f…e496cc
0.3.19Cached · Upstream SHA-256 matchedDownload83ea5ffd…0b8779
0.3.20Cached · Upstream SHA-256 matchedDownloadde431744…2ac9ab
0.3.21Cached · Upstream SHA-256 matchedDownload17c84b88…99609b
0.3.22Cached · Upstream SHA-256 matchedDownload5cb985a3…2e939a
0.3.24Cached · Upstream SHA-256 matchedDownload6baac2a7…c4ef60
0.3.25Cached · Upstream SHA-256 matchedDownload55b1b751…3d371f
0.4.0Cached · Upstream SHA-256 matchedDownloadf16b4c82…f1b045
0.4.1Cached · Upstream SHA-256 matchedDownloada78d65a3…b204ec
0.4.2Cached · Upstream SHA-256 matchedDownloadbff12d4e…331493
0.4.3Cached · Upstream SHA-256 matchedDownload95e65662…cbb822
0.4.4Cached · Upstream SHA-256 matchedDownload839ac5b0…c194d5
0.4.5Cached · Upstream SHA-256 matchedDownloada104543d…2fce1d
0.4.6Cached · Upstream SHA-256 matchedDownload9a272d97…292d0d
0.4.7Cached · Upstream SHA-256 matchedDownloadd62c6d02…a7a464
0.4.8Cached · Upstream SHA-256 matchedDownloadb6df4602…5f5e1f
0.5.0Cached · Upstream SHA-256 matchedDownloadaf8cbcbd…8167a7
0.5.1Cached · Upstream SHA-256 matchedDownloadc3c1a58f…2c9691
0.6.0Cached · Upstream SHA-256 matchedDownloadc4ebe9fd…55994a
0.6.1Cached · Upstream SHA-256 matchedDownload59e032b1…a36028
0.6.1+1Cached · Upstream SHA-256 matchedDownload8d218fbb…48c0b2
0.6.1+2Cached · Upstream SHA-256 matchedDownloade660f25c…01610f
0.6.2Cached · Upstream SHA-256 matchedDownload245a4d94…e2d7d9
0.6.2+1Cached · Upstream SHA-256 matchedDownload06bd3411…0436d4
0.6.3Cached · Upstream SHA-256 matchedDownloada5e57e36…f4a501
0.6.3+1Cached · Upstream SHA-256 matchedDownloadfba0cee1…596dc1
0.6.3+2Cached · Upstream SHA-256 matchedDownload261a1872…9b72a5
0.6.3+3Cached · Upstream SHA-256 matchedDownloada0dc3e2e…daa80d
0.6.3+4Cached · Upstream SHA-256 matchedDownload26d6714c…3e8c9a
0.6.3+5Cached · Upstream SHA-256 matchedDownload85e45a6e…e61b28
0.7.0Cached · Upstream SHA-256 matchedDownload511f6ced…df1e08
0.7.1Cached · Upstream SHA-256 matchedDownloade1a3868e…fa8e06
0.7.1+1Cached · Upstream SHA-256 matchedDownloade8635809…8b6691
0.8.0Cached · Upstream SHA-256 matchedDownload270cc269…58d957
0.8.1Cached · Upstream SHA-256 matchedDownloade4f6c2dd…385b6c
0.8.2Cached · Upstream SHA-256 matchedDownloadaf8fb9bf…1ec1d8
0.8.2+1Cached · Upstream SHA-256 matchedDownload27eb06b2…733192
0.8.2+2Cached · Upstream SHA-256 matchedDownload2d038075…c2b1b3
0.8.3+1Cached · Upstream SHA-256 matchedDownloadb8ece876…e86179
0.9.0Cached · Upstream SHA-256 matchedDownloada0e99914…f05176
0.10.0Cached · Upstream SHA-256 matchedDownload7ffd2c08…7cdcf2
0.10.1Cached · Upstream SHA-256 matchedDownload20d23b04…ca4f06
0.10.2Cached · Upstream SHA-256 matchedDownload7996ad01…53d9a1
0.11.0Cached · Upstream SHA-256 matchedDownload98d9da96…afacdf
0.12.0Cached · Upstream SHA-256 matchedDownloadd033fe80…3e3a6b
0.13.0Cached · Upstream SHA-256 matchedDownload18c6280d…d37fec
0.13.1Cached · Upstream SHA-256 matchedDownload0a94c626…edd512
0.14.0Cached · Upstream SHA-256 matchedDownload5fdd2cfc…a9ce71
0.14.0+1Cached · Upstream SHA-256 matchedDownload9d30cde3…ae177f
0.14.0+2Cached · Upstream SHA-256 matchedDownloada1e7dd1d…9939a1
0.15.0Cached · Upstream SHA-256 matchedDownload1a25d2da…699ef1
0.15.1Cached · Upstream SHA-256 matchedDownloade4133253…4b0378
0.16.0Cached · Upstream SHA-256 matchedDownload6b47d4ca…824efc
0.16.0+1Cached · Upstream SHA-256 matchedDownloadb53243a8…341ce9
0.16.0+2Cached · Upstream SHA-256 matchedDownloadae15fbca…5e47ea
0.16.1Cached · Upstream SHA-256 matchedDownload4c7c36b2…7e2678
0.16.2Cached · Upstream SHA-256 matchedDownloadce20f885…610bc2
0.16.3Cached · Upstream SHA-256 matchedDownload47531cc1…ab9d30
0.16.4Cached · Upstream SHA-256 matchedDownload1ec7cde3…6132ad
0.16.5Cached · Upstream SHA-256 matchedDownload3fee42bc…e41a28
0.16.6Cached · Upstream SHA-256 matchedDownloadc71a72d4…62f1c3
0.16.7Cached · Upstream SHA-256 matchedDownload4c2dedb2…aa84a6
0.17.0Cached · Upstream SHA-256 matchedDownloadb0d6865d…24959b
0.18.0Cached · Upstream SHA-256 matchedDownload864a5f32…72ba2e
0.18.1Cached · Upstream SHA-256 matchedDownload8f4130f9…9f7e0d
0.19.0Cached · Upstream SHA-256 matchedDownload4097cc92…19e131
0.20.0Cached · Upstream SHA-256 matchedDownload3f3b7a45…71ac6e
0.21.0Cached · Upstream SHA-256 matchedDownload18a5e310…d23bfb
0.22.0Cached · Upstream SHA-256 matchedDownload3b4c1c24…3a10c4
0.22.1Cached · Upstream SHA-256 matchedDownloadc934cbbb…31acbe
0.22.1+1Cached · Upstream SHA-256 matchedDownloada85b911a…432577
0.22.2Cached · Upstream SHA-256 matchedDownloadd3e28dab…88bb1d
0.22.3Cached · Upstream SHA-256 matchedDownload87acf1eb…e1d3e5
0.22.4Cached · Upstream SHA-256 matchedDownload916aa71a…a6c21d
0.22.5Cached · Upstream SHA-256 matchedDownload83c06171…276da5
0.22.6Cached · Upstream SHA-256 matchedDownload79022a7d…2e1241
0.23.0-dev.1Cached · Upstream SHA-256 matchedDownload0b03b203…8204de
0.23.0-dev.2Cached · Upstream SHA-256 matchedDownloadb2968d8b…265c98
0.23.0-dev.3Cached · Upstream SHA-256 matchedDownload685f66f6…687e34
0.23.0Cached · Upstream SHA-256 matchedDownload13455e1c…957209
0.23.1Cached · Upstream SHA-256 matchedDownload4bae6903…f35d88
0.24.0-dev.1Cached · Upstream SHA-256 matchedDownload11e59b31…f968a5
0.24.0Cached · Upstream SHA-256 matchedDownload09b328f6…1f1a2e
0.24.1Cached · Upstream SHA-256 matchedDownload0beed421…2aa97e
0.25.0-betaCached · Upstream SHA-256 matchedDownloadeb1ac150…fb494d
0.25.0-beta2Cached · Upstream SHA-256 matchedDownload6a055724…e5ae99
0.25.0-beta3Cached · Upstream SHA-256 matchedDownloadfb4eb6f4…aa37a5
0.25.0Cached · Upstream SHA-256 matchedDownloadc7cd7cee…d9e3c3
0.26.0-nullsafety.0Cached · Upstream SHA-256 matchedDownload540ef29a…48159c
0.26.0-nullsafety.1Cached · Upstream SHA-256 matchedDownloadee3719e8…8415fe
0.26.0Cached · Upstream SHA-256 matchedDownload2ef8b4e9…cc21fd
0.27.0Cached · Upstream SHA-256 matchedDownload3f7cb435…091f90
0.27.1Cached · Upstream SHA-256 matchedDownloade59cd262…e853d9
0.27.2Cached · Upstream SHA-256 matchedDownload7358d9e1…e3d5d6
0.27.3Cached · Upstream SHA-256 matchedDownloadbc2d2b17…39c46d
0.27.4Cached · Upstream SHA-256 matchedDownload933db292…2888cb
0.27.5Cached · Upstream SHA-256 matchedDownload5d22055f…b0209c
0.27.6Cached · Upstream SHA-256 matchedDownload46383ce2…1952bf
0.27.7Cached · Upstream SHA-256 matchedDownload0c7c0ced…0044cb
0.28.0-dev.0Cached · Upstream SHA-256 matchedDownload93bca4fe…c82cdf
0.28.0-dev.1Cached · Upstream SHA-256 matchedDownload5a11abd6…6be690
0.28.0-dev.2Cached · Upstream SHA-256 matchedDownloade5507e36…378d3c
0.28.0Cached · Upstream SHA-256 matchedDownload5c3004a4…d1a962

Dependencies

No direct dependencies declared.