@phylum/rxjs
v1.0.0
Published
RxJS Integration
Downloads
1
Readme
@phylum/rxjs
RxJS Integration
Installation
npm i @phylum/pipeline @phylum/rxjs rxjs
Creating observables
Pipeline tasks can be wrapped into observables that push objects with an error
or with a value
property representing the task result.
import { createObservable } from '@phylum/rxjs';
const task = new Task(async () => {
return 'Hello World!';
})
const observable = createObservable(task);
observable.subscribe(({ value, error }) => {
if (error) {
console.error(error);
} else {
console.log(value);
}
});
Creating tasks
Observables can be wrapped into tasks that emit results for each value or error that is pushed by the observable.
import { createTask } from '@phylum/rxjs';
const observable = new Observable(subscriber => {
subscriber.next('Hello World!');
})
const task = createTask(observable);
new Task(async t => {
console.log(await t.use(task));
})