1.0.0 • Published 5 years ago

@phylum/rxjs v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

@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));
})