1.0.0 • Published 7 years ago
@phylum/rxjs v1.0.0
@phylum/rxjs
RxJS Integration
Installation
npm i @phylum/pipeline @phylum/rxjs rxjsCreating 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));
})1.0.0
7 years ago