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

rxjs-etc

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rxjs-etc

Observables and operators for RxJS

  • 9.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.3K
decreased by-78.87%
Maintainers
1
Weekly downloads
 
Created
Source

rxjs-etc

GitHub License NPM version Build status dependency status devDependency Status peerDependency Status Greenkeeper badge

What is it?

A bunch of observables and operators for RxJS.

Why might you need it?

I created this package as a place to put additional RxJS observables, operators and methods. If you are looking for something that's not in the RxJS distribution, there might be something suitable in here - if you're lucky.

Install

Install the package using NPM:

npm install rxjs-etc --save

What's in it?

Observable factories

  • combineLatestArray, concatArray, forkJoinArray, mergeArray, zipArray

    A bunch of static methods that behave in a predictable manner when passed empty arrays. Some of these are now redundant, but some aren't.

    To see how these methods behave, consult their tests.

  • combineLatestHigherOrderArray, combineLatestHigherOrderObject

    Higher-order variants of combineLatestArray - that takes Observable<Observable<T>[]> and returns Observable<T[]> - and combineLatestObject.

  • combineLatestObject, forkJoinObject

    Like the array versions, but these take objects. Observable properties are combined using either combineLatest or forkJoin.

  • forkJoinConcurrent

    Like forkJoin but only runs the specified number of observables concurrently.

  • mergeHigherOrderArray

    Higher-order variant of mergeArray - that takes Observable<Observable<T>[]> and returns Observable<T>.

  • separate

    Like partition but can passed more than one predicate to return more than two observables.

  • toggle

    Splits a notifier into two or more states and between which notifications are toggled.

  • traverse

    Based on expand. Traverses a graph - with backpressure control - using either a notifier or a consumer.

  • zipPadded

    Works like zipArray, but if some sources complete whilst others continue to emit values, those the complete are 'padded' with the specified padValue (which defaults to undefined).

Functions for use with pipe or let

A bunch of functions that can be passed to the let operator. Use them like this:

source.let(endWith("this is the end"))

They can also be used with pipe, like this:

source.pipe(endWith("this is the end"))
  • bufferRecent

    Buffers the specified number of most-recent values.

  • concatIfEmpty

    Like defaultIfEmpty, but it takes a default observable instead of a default value.

  • debounceAfter

    Debounce the source observable, but only after the notifier emits a value.

  • debounceTimeSubsequent

    Debounce the source observable, but don't debounce the first count notifications - only the subsequent notifications.

  • debounceTimeWithinReason

    Like debounceTime, but with an additional duration to ensure some notifications are emitted for super-busy streams.

  • endWith

    Like startWith, but for the other end.

  • guard

    Applies the specified TypeScript guard to change the source observable's type and perform a runtime check. Emits an error notification if the guard rejects a value.

  • hasCompleted

    Emits true when the source observable completes.

  • indexElements

    Like map((value, index) => index) when it's called without a selector. When called with a selector, it's just an alias for map.

  • inexorably

    Like finalize (which is also exported as an alias), but passes the callback the Notification that effected the teardown, or undefined if explicitly unsubscribed.

  • initial

    Apply the operator to the source observable, but select only the initial count notifications - don't select the subsequent notifications.

  • pairwiseStartWith

    Like a combination of startWith and pairwise, but with more specific typings.

  • pluck

    Like pluck, but it's type-safe and only lets you valid keys. And it returns the appropriate type.

  • prioritize

    When creating signals from a source observable - for use with operators that take a notifier, like buffer and window - the order in which subscriptions are made is important. prioritize can be used to ensure that the notifier subscribes to the source first.

  • rateLimit

    A rate limiter with pass through when waiting is not necessary.

  • refCountDelay

    Can be used with a ConnectableObservable instead of refCount. When the reference count drops to zero, it waits the specified duration and then if the reference count is zero, it unsubscribes. If the reference count is incremented within the duration, no unsubscription occurs.

  • refCountForever

    Somewhat like the change that was made to shareReplay in 5.5.0.beta.4. When first subscribed to, a subscription is made to the source, but the source is never explicitly unsubscribed from. Unsubscription from the source only occurs if the source completes or errors.

  • refCountOn

    Like refCount, but performs connections and unsubscriptions on the specified scheduler.

  • reschedule

    Emits values using the specified scheduler.

  • startWithTimeout

    Like startWith but only emits the starting value if the source does not emit within the specified duration.

  • subsequent

    Apply the operator to the source observable, but don't select the first count notifications - only the subsequent notifications.

  • takeWhileInclusive

    Like takeWhile, but the value that fails the predicate is taken.

  • tapWithIndex

    Like tap, but it receives a tuple that includes the emitted value and the index.

  • throttleAfter

    Throttle the source observable, but only after the notifier emits a value.

  • unsubscribeOn

    Like subscribeOn, but for unsubscription.

Utility functions

A bunch of utility functions that do what their names suggest:

  • genericPipe

    Like the static pipe (which is also exported as an alias), but with an overload signature that will return a generic operator if all parameter types are the same. For example, the debounceTime and distinctUntilChanged operators don't alter the observable type, so it's possible to return a generic type:

    const debounce = genericPipe(
      debounceTime(400),
      distinctUntilChanged()
    ); // <R extends {}>(source: Observable<R>) => Observable<R>
    

    The returned, generic debounce function can then be used in pipe calls made on observables of any type. And it's type-safe.

  • isNullish/isNotNullish

    isNullish returns true if a value is null or undefined.

  • isObservable

  • isScheduler

Keywords

FAQs

Package last updated on 12 Oct 2018

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