# any-observable

> Support any Observable library and polyfill

Latest version **0.6.0** (published 2026-02-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install any-observable
pnpm add any-observable
yarn add any-observable
bun add any-observable
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.6.0 |
| Published | 2026-02-02 |
| First published | 2016-04-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 0 |
| Unpacked size | 12.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 74 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | observable, observables, support, polyfill, any, rxjs |

## Links

- npm: https://www.npmjs.com/package/any-observable
- Repository: https://github.com/sindresorhus/any-observable
- Homepage: https://github.com/sindresorhus/any-observable#readme
- Issues: https://github.com/sindresorhus/any-observable/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/any-observable

## Recent versions

- 0.6.0 (latest) — 2026-02-02
- 0.5.1 — 2020-01-25
- 0.5.0 — 2019-09-23
- 0.4.0 — 2019-05-28
- 0.3.0 — 2018-04-19
- 0.2.0 — 2016-06-27
- 0.1.1 — 2016-04-27
- 0.1.0 — 2016-04-27

## README

# any-observable

> Support any [Observable](https://github.com/zenparsing/es-observable) library and polyfill

## Install

```sh
npm install any-observable
```

You must also install the Observable library you want:

```sh
npm install zen-observable
```

## Usage

```js
import Observable from 'any-observable'; // Using `zen-observable` since it's installed

Observable.of(1, 2).forEach(value => {
	console.log(value);
});
//=> 1
//=> 2
```

## Optional import

If you want to attempt loading without throwing, use the optional entrypoint. It returns `undefined` when no implementation is available:

```js
import Observable from 'any-observable/optional';

if (Observable === undefined) {
	console.log('No Observable implementation available');
}
```

## Registration Shortcuts

This adds the following shortcut registrations:

- `rxjs-min`: Bare bones [RxJs](https://github.com/ReactiveX/rxjs) Observable implementation. See the [RxJs Installation Instructions](http://reactivex.io/rxjs/manual/installation.html) for details on patching additional methods into that implementation.
- `rxjs`: Same as `rxjs-min`, but adds the somewhat standard `Observable.of` and `Observable.from`.
- `rxjs-all`: The kitchen sink approach to Observables.
- `zen`: The [`zen-observable`](https://github.com/zenparsing/zen-observable) implementation.

Shortcut registration can be done as follows:

```js
import 'any-observable/register/zen';
```

It's especially handy for environments that support preloading ESM modules:

```sh
node --import=any-observable/register/zen test.js
```

## Browser native ESM registration

Use the async helper when you want to probe multiple implementations in a browser native ESM setup:

```js
import registerAsync from 'any-observable/register/async';

await registerAsync([
	'rxjs',
	'zen-observable'
]);

const {default: Observable} = await import('any-observable');
```

This requires import maps or URL specifiers for the implementations you probe, and it must run before any `import 'any-observable'`.

## Compatibility and interop

`any-observable` expects an ES Observable implementation (a constructor), not just interop on stream instances. Libraries like most, Kefir, Bacon, xstream, and Flyd are not supported directly unless they provide an ES Observable constructor. If your library can convert to an ES Observable, use that and register explicitly:

```js
import register from 'any-observable/register';

register('custom', {Observable: YourObservable});
```

## For library authors

If your library depends on Observables via `any-observable`, follow these guidelines:

- **Do not call `register` yourself.** Leave Observable implementation choice to the end user.
- **Do not rely on non-standard features.** Stick to the [ES Observable spec](https://github.com/zenparsing/es-observable) so any compliant implementation works.
- **Document `any-observable` support prominently.** Let users know they need to install and register an Observable implementation.

## Related

- [is-observable](https://github.com/sindresorhus/is-observable) - Check if a value is an Observable
- [observable-to-promise](https://github.com/sindresorhus/observable-to-promise) - Convert an Observable to a Promise

---
_Source: https://npm.io/package/any-observable · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
