New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

static-observable

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

static-observable

Static observable methods `next`, `error`, and `complete`. Equivalent to `Promise.resolve()` and `Promise.reject()` for promises.

latest
Source
npmnpm
Version
1.0.5
Version published
Maintainers
1
Created
Source

static-observable Build Status js-standard-style

Static observable methods next, error, and complete. Equivalent to Promise.resolve() and Promise.reject() for promises.

Installation

npm i --save static-observable
npm i --save rxjs # peer dependency

Why?

For quick return cases and test stubs

Usage

Example: chain

var StaticObservable = require('static-observable')

var observable = StaticObservable
  .next({ foo: 1 })
  .next({ foo: 2 })
  .complete()

observable.subscribe(
  function (next) { console.log('NEXT:', next )},
  function (err) { console.log('ERROR:', err )},
  function () { console.log('COMPLETE' )}
)
// NEXT: { foo: 1 }
// NEXT: { foo: 2 }
// COMPLETE

Example: error chain

var StaticObservable = require('static-observable')

var observable = StaticObservable
  .next({ foo: 1 })
  .next({ foo: 2 })
  .error(new Error('boom'))

observable.subscribe(
  function (next) { console.log('NEXT:', next )},
  function (err) { console.log('ERROR:', err )},
  function () { console.log('COMPLETE' )}
)
// NEXT: { foo: 1 }
// NEXT: { foo: 2 }
// ERROR: [Error: boom]

Example: error and complete are "safe"

var StaticObservable = require('static-observable')

var observable = StaticObservable
  .error(new Error('boom'))
  .next({ foo: 1 })

observable.subscribe(
  function (next) { console.log('NEXT:', next )},
  function (err) { console.log('ERROR:', err )},
  function () { console.log('COMPLETE' )}
)
// ERROR: [Error: boom]

var observable = StaticObservable
  .complete(new Error('boom'))
  .next({ foo: 1 })

observable.subscribe(
  function (next) { console.log('NEXT:', next )},
  function (err) { console.log('ERROR:', err )},
  function () { console.log('COMPLETE' )}
)
// COMPLETE

License

MIT

Keywords

observable

FAQs

Package last updated on 22 Mar 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