This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@saferx/safe
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

Safe operators

npm version

Materialize start and end of operator

Contains ready-made operators:

  • Safe operators - ready-made safe operators:
    • safeSwitchMap
    • safeConcatMap
    • safeMergeMap
    • safeExhaustMap (TODO)
    • safeMergeScan
  • Part operators - ready-made data-enriching operators:
    • ProgressPart
    • UpdatedAtPart

Other "safe" extensions and utilities for RxJS

Installation

npm i @saferx/safe

Usage

import { safeSwitchMap, ProgressPart, UpdatedAtPart, Safe } from "@saferx/safe";
import { of } from "rxjs";
import { delay, shareReplay } from "rxjs/operators";

const helloWorld$ = of("world").pipe(
    safeSwitchMap((name) => of(`Hello, ${name}!`).pipe(delay(1000))),
    ProgressPart.Add(),
    UpdatedAtPart.Add(),
    shareReplay(1)
);

helloWorld$.pipe(ProgressPart.Select()).subscribe((value) => console.log("progress:", value));
helloWorld$.pipe(UpdatedAtPart.Select()).subscribe((value) => console.log("updatedAt:", value));
helloWorld$.pipe(Safe.SelectValue()).subscribe((value) => console.log("value:", value));
helloWorld$.pipe(Safe.SelectError()).subscribe((value) => console.log("error:", value));

// progress: false
// progress: true
// value: Hello, world!
// progress: false
// updatedAt: 2021-04-10T22:34:31.790Z
// error: undefined

Package Sidebar

Install

npm i @saferx/safe

Weekly Downloads

1

Version

0.4.0

License

MIT

Unpacked Size

51.4 kB

Total Files

78

Last publish

Collaborators

  • krickray