Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@reactive-js/observable

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reactive-js/observable

Reactive-Js's core reactive programming API.

  • 0.0.36
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by66.67%
Maintainers
1
Weekly downloads
 
Created
Source

@reactive-js/observable

Reactive-Js's core reactive programming API.

Reactive-Js unifies reactive and interactive programming into a single API, defined by two core interfaces: ObservableLike and EnumerableLike. In addition, basic utilities for safely creating, transforming, and using ObservableLike and EnumerableLike streams are provided.

ObservableLike streams are always asynchronous. Subscribing only sets up subscription, but does not synchronously produce values (doing so is a programming error). Instead scheduling is deeply integrated into the SubscriberLike type. During subscription setup, ObservableLike sources schedule work to be done in the future, such as iterating through an iterable source. This enables tight integrationg with platform specific scheduling implementations such as React's internal scheduler.

A note on backpressure

While reactive-js does not provide an API to directly apply backpressure to an ObservableLike source, the library does provided several primitives that can be used to achieve the effect.

CPU bound backpressure can be achieved via the @reactive-js/scheduler SchedulerLike interface's support for cooperative multi-tasking. Specifically, ObservableLike sources must honor a SchedulerLike's shouldYield requests, yielding control back to the scheduler, and returning a SchedulerContinuationLike if additional work is to be completed.

A second approach is provided by the @reactive-js/async-enumerable package, which defines a push/pull interface for iterating through asynchronous producers.

Installation

via npm

npm install @reactive-js/observable

via yarn

yarn add @reactive-js/observable

Usage

import { subscribe } from "@reactive-js/observable";
import { pipe } from "@reactive-js/pipe";

const observableSource;
const platformScheduler;

// Setup a subscription to the observableSource using the platform scheduler
const subscription = pipe(observableSource, subscribe(platformScheduler));

// ...later in the future

// Dispose the observable subscription
subscription.dispose();

Documentation

API documentation is available here.

Keywords

FAQs

Package last updated on 21 Apr 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc