Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/web-mech/can-stream-x
Stream values into and out of computes
https://github.com/web-mech/can-stream-x
baconjs can-stream canjs kefir rxjs stream
Last synced: 24 days ago
JSON representation
Stream values into and out of computes
- Host: GitHub
- URL: https://github.com/web-mech/can-stream-x
- Owner: web-mech
- License: mit
- Created: 2017-04-21T05:19:00.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-05-03T21:22:33.000Z (over 7 years ago)
- Last Synced: 2024-11-20T05:27:58.867Z (about 1 month ago)
- Topics: baconjs, can-stream, canjs, kefir, rxjs, stream
- Language: JavaScript
- Size: 26.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# can-stream-x
[![Build Status](https://travis-ci.org/web-mech/can-stream-x.svg?branch=master)](https://travis-ci.org/web-mech/can-stream-x)
Stream values into and out of computes using any streaming lib.
Great for streaming libs that return emitters as a callback.## Syntax
```
canStreamX([options]);
```### Notes
- Passing falsey values for the emitter flag makes indicates the emitter is a function and should be called directly.
- Passing falsey values for the unsubscribe method indicates the unsubscribe method is derived from the subscribe method.### Options
- streamConstructor - method necessary to create a stream.
- emitMethod - Which method to use as the emitter.
- on - Which method to use to subscribe.
- off - Which method to use to unsubscribe.## Example Usage
### Using RxJs
```
var canStreamX = require('./can-stream-x');
var Rx = require('rxjs');
var Observable = Rx.Observable;var canStream = canStreamX({
streamConstructor: Observable.create,
emitMethod: 'next',
on: 'subscribe',
off: 'unsubscribe'
});var c = compute(0);
var stream = canStream.toStream(c);
var computeVal;
stream.subscribe((newVal) => {
computeVal = newVal;
});c(1);
console.log(computeVal); //1
```### Using Kefir
```
var canStreamX = require('./can-stream-x');
var Kefir = require('kefir');
var canStream = canStreamX({
streamConstructor: Kefir.stream,
emitMethod: 'emit',
on: 'onValue',
off: 'offValue'
});
...
```### Using Bacon
```
var canStreamX = require('./can-stream-x');
var Bacon = require('bacon');
var canStream = canStreamX({
streamConstructor: Bacon.fromBinder,
on: 'onValue',
off: false
});
...
```## testing
```
npm test
```