https://github.com/lostintime/node-rx-stream
Reactive Streams implementation with TypeScript
https://github.com/lostintime/node-rx-stream
javascript nodejs reactive-streams typesafe typescript
Last synced: 3 months ago
JSON representation
Reactive Streams implementation with TypeScript
- Host: GitHub
- URL: https://github.com/lostintime/node-rx-stream
- Owner: lostintime
- License: apache-2.0
- Created: 2017-12-02T15:08:35.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-12T16:12:26.000Z (over 8 years ago)
- Last Synced: 2025-02-22T18:51:23.694Z (over 1 year ago)
- Topics: javascript, nodejs, reactive-streams, typesafe, typescript
- Language: TypeScript
- Size: 141 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
RxStream
========
TypeScript port of [Monix](https://github.com/monix/monix) reactive streams module.
All credits goes to [monix authors](https://github.com/monix/monix/graphs/contributors)!
## WARNING! Work in progress!
This library is [Work in Progress](./TODO.md), api may change until version `1.0.0`.
## Usage
Install `rx-stream` library:
```$bash
npm install --save rx-stream
```
### Hello World
Create an `Observable` and observe it's events:
```$typescript
import Observable from 'rx-stream';
import {Future} from 'funfix';
Observable.range(0, 10)
.mapFuture(n => Future.pure(n).delayResult(1000))
.foreach((e) => {
console.log('got item', e);
})
```
### `takeUntil` for synchronous sources
For synchronous sources, in order to use `takeUntil` and `onErrorRestart` - need to add
_asyncBoundary_ (ex: `bufferWithPressure`), otherwise event loop may never reach `takeUntil`
```$typescript
let failed = false;
Observable.loop()
.map((n): number => {
// will throw here
if (n == 3 && !failed) {
failed = true;
throw new Error('something went wrong');
}
return n;
})
.bufferWithPressure(10) // this will break synchronous loop, to "make room" async events (sigTrigger)
.onErrorRestartUnlimited()
.takeUntil(sigTrigger)
```
## Documentation
More usage examples and documentation will come closer to version `1.0`
## License
All code in this repository is licensed under the Apache License, Version 2.0. See [LICENCE](./LICENSE).