Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/deebloo/rxjs-worker
Standard rxjs operators built to run in web workers
https://github.com/deebloo/rxjs-worker
Last synced: about 2 months ago
JSON representation
Standard rxjs operators built to run in web workers
- Host: GitHub
- URL: https://github.com/deebloo/rxjs-worker
- Owner: deebloo
- License: mit
- Created: 2016-06-30T19:10:09.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T11:55:58.000Z (about 1 year ago)
- Last Synced: 2024-11-01T11:51:34.544Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 55.7 KB
- Stars: 17
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rxjs-worker [![CircleCI](https://circleci.com/gh/deebloo/rxjs-worker.svg?style=svg)](https://circleci.com/gh/deebloo/rxjs-worker)
RXJS extensions for adding web worker functionality via operators and observables
## Observables
### observable.fromWorker()
Create an observable from a webworker, path, or function
```TS
// web worker
const myWorker = new Worker('path/to/web-worker.js');
const observable1 = Observable.fromWorker(myWorker);// function
const observable2 = Observable.fromWorker(() => {
self.postMessage('Hello World');
});// string
const observable3 = Observable.fromWorker('path/to/web-worker.js');
```## Operators
### observable.mapWorker()
simple map function that runs in a web worker
```TS
Observable
.from(['Hello World'])
.mapWorker(strng => {
return strng + ', I am from a worker.';
})
.subscribe(res => {
console.log(res); // Hello World, I am from a worker
});
```### observable.filterWorker()
returns either the result or null
```TS
Observable
.from(['Hello World'])
.filterWorker(strng => {
return strng === 'Hello World';
})
.subscribe(res => {
console.log(res); // Hello World
});
```