This library aims to provide Observable based APIs, that wrap Web APIs.
Some of the Web APIs covered here are experimental, non-standard, and/or not well-supported. If necessary, polyfills need to be provided by the user of this library.
The public API surface of this library can be affected by breaking changes within the experimental API used.
Additionally, the implementation of this library makes use of globalThis which breaks ie <= 11! There is no plan to add support for IE 11 in this library.
rxjs-web
is available via npm:
npm i rxjs-web
N.B.: This library relies on RxJS >= 6 and expects you already have it installed in your project.
General hint: usually promise-based APIs are eager, while Observable-based APIs of this library are lazy (executed/started upon subscription). This design decision was made due to the general specification of RxJS Observables.
π IntersectionObserver | π¬ experimental
...
π MutationObserver
...
π PerformanceObserver | π¬ experimental
...
π ResizeObserver | π¬ experimental
...
π dynamic import
...
π matchMedia
...
π Network Information API | π¬ experimental
...
π Permission API | π¬ experimental
...
π Geolocation API
...
π Sensor APIs | π¬ experimental
...
π SpeechSynthesis | π¬ not well tested
speak
provides handy interface for chaining and aborting synthesis.
import { speak } from 'rxjs-web';
speak('Hello!').subscribe();
import { speak } from 'rxjs-web';
concat(
speak('Hello, mom!'),
speak('How are you?'),
speak('I miss you.'),
).subscribe();
import { of, merge, concat, timer } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { speak, SpeechSynthesisUtteranceConfig } from 'rxjs-web';
const a: string = 'Hello, mom!';
const b: SpeechSynthesisUtteranceConfig = {
text: 'How are you?',
lang: 'en-UK',
pitch: 1,
rate: 1,
volume: 1,
};
const c = new SpeechSynthesisUtterance('I miss you');
c.rate = 1;
c.lang = 'en-US';
c.pitch = 1;
c.rate = 1;
c.volume = 1;
concat(speak(a), speak(b), speak(c)).subscribe((e: SpeechSynthesisEvent) => {
console.log(e.name);
console.log(e.type);
});
π SpeechRecognition | π¬ not well tested
Handy interface for continuous speech recognition.
import { listen } from 'rxjs-web';
listen({ lang: 'en' })
.subscribe(e => {
if (e.type == 'result') {
console.log(e.results[0][0].transcript);
}
});
These APIs are not yet supported by this library, and might be included later:
Name / Link |
---|
Vibration API |
Bluetooth API |
File and Directory Entries API |
Image Capture API |
Push API |
Broadcast Channel API |
That will be awesome!
Please create an issue before submitting a PR β we'll be able to discuss it first!
Thanks!
This project is build upon the typescript library starter. Kudos to @alexjoverm and every contributor of this amazing project!
Many thanks also goes to Sascha for creating this fantastic logo!