You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

rxjs-addons

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rxjs-addons

Rx add-ons


Version published
Weekly downloads
102
increased by175.68%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Rx add-ons

NPM version

Installation

$ npm i rxjs-addons -S

Example usage

AttributesProxySubject

import { AttributesProxySubject } from "rxjs-addons";
const subject = new AttributesProxySubject({
  a: 1,
  b: 2,
}, {
  schema: {
    a: {
      getter: true,
      setter: true
    },
    b: {
      subject,
    },
  },
});

console.log(subject.a) // 1
console.log(subject.b) // undefined

subject.b$.subscribe((value) => console.log("b:", value));

/*
  b: 2
 */

ErrorSubject

import { ErrorSubject } from "rxjs-addons";
const subject = new ErrorSubject();

subject.subscribe((err) => console.error(err));

// regular catch
try {
  throw new Error("Error");
} catch (err) {
  subject.error(err); // or errorSubject.next(err); 
}

// wrapping promise or async function 
subject.wrapAsync(async () => {
  throw new Error("Error");
});
subject.wrapAsync(Promise.reject(new Error("Error")));

// wrapping promise or async function and return promise
subject
  .wrapTAsync<string>(async () => {
    ... // 
    return "value";
  })
  .then((value) => console.log(value));

UniqueBehaviorSubject

import { UniqueBehaviorSubject } from "rxjs-addons";
const subject = new UniqueBehaviorSubject(1); // with default value

console.log(subject.value); // 1

subject.next(2);
subject.next(2);
subject.next(2);
subject.next(3);
subject.next(3);

subject.subscribe((value) => console.log("value:", value));

/*
  value: 1
  value: 2
  value: 3
 */

Testing

$ npm test

License

The MIT License

FAQs

Package last updated on 09 Jan 2019

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc