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

observable-fns

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

observable-fns

Light-weight observable implementation and utils written in TypeScript. Based on zen-observable.

  • 0.6.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is observable-fns?

The observable-fns package provides a set of utilities for working with observables in JavaScript. It is designed to be lightweight and easy to use, offering a range of functionalities for creating, transforming, and managing observables.

What are observable-fns's main functionalities?

Creating Observables

This feature allows you to create new observables. The example demonstrates creating an observable that emits 'Hello' and 'World' before completing.

const { Observable } = require('observable-fns');

const observable = new Observable(observer => {
  observer.next('Hello');
  observer.next('World');
  observer.complete();
});

observable.subscribe({
  next: value => console.log(value),
  complete: () => console.log('Done')
});

Transforming Observables

This feature allows you to transform the values emitted by an observable. The example shows how to use the `map` operator to double the values emitted by the original observable.

const { Observable, map } = require('observable-fns');

const observable = new Observable(observer => {
  observer.next(1);
  observer.next(2);
  observer.next(3);
  observer.complete();
});

const transformed = observable.pipe(map(x => x * 2));

transformed.subscribe({
  next: value => console.log(value),
  complete: () => console.log('Done')
});

Combining Observables

This feature allows you to combine multiple observables into one. The example demonstrates merging two observables that emit 'A' and 'B' respectively.

const { Observable, merge } = require('observable-fns');

const observable1 = new Observable(observer => {
  observer.next('A');
  observer.complete();
});

const observable2 = new Observable(observer => {
  observer.next('B');
  observer.complete();
});

const combined = merge(observable1, observable2);

combined.subscribe({
  next: value => console.log(value),
  complete: () => console.log('Done')
});

Other packages similar to observable-fns

FAQs

Package last updated on 30 May 2021

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