Socket
Socket
Sign inDemoInstall

any-observable

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    any-observable

Support any Observable library and polyfill


Version published
Weekly downloads
1.8M
decreased by-3.59%
Maintainers
1
Install size
9.52 kB
Created
Weekly downloads
 

Package description

What is any-observable?

The any-observable package allows you to register an Observable library of your choice and use it throughout your application as a singleton. This means you can use Observables without being locked into a specific library, providing flexibility in your codebase.

What are any-observable's main functionalities?

Registering a specific Observable implementation

This feature allows you to register an Observable implementation that will be used whenever you import 'any-observable'.

const anyObservable = require('any-observable');
anyObservable.register('rxjs'); // or 'zen-observable', etc.

Using the registered Observable

Once an Observable library is registered, you can create and use Observables as you would normally with that library.

const Observable = require('any-observable');
const stream = new Observable(observer => {
  observer.next('Hello, World!');
  observer.complete();
});

stream.subscribe({
  next: console.log,
  complete: () => console.log('Stream finished')
});

Other packages similar to any-observable

Readme

Source

any-observable Build Status

Support any Observable library and polyfill

Like any-promise. (Docs are lacking here, so refer to those docs for now)

Install

$ npm install any-observable

You must also install the Observable library you want:

$ npm install zen-observable

Usage

const Observable = require('any-observable'); // Using `zen-observable` since it's installed

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

Registration Shortcuts

This adds the following shortcut registrations:

  • rxjs-min: Bare bones RxJs Observable implementation. See the RxJs Installation Instructions 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 implementation.

Shortcut registration can be done as follows:

import 'any-observable/register/zen';

It's especially handy for more recent versions of Node.js (and many test runners), that offer a --require flag:

$ ava --require=any-observable/register/zen test.js

Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Keywords

FAQs

Last updated on 25 Jan 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc