Options
All
  • Public
  • Public/Protected
  • All
Menu

Module utility

Index

Type aliases

RxJS Boolean Validation Functions

RxJS Observable Utilities Functions

Type aliases

CallbackFn

CallbackFn: () => void

Type declaration

    • (): void
    • Returns void

QueryMethod

QueryMethod<T>: (query: string) => ObservableInput<T>

A function passed to debounceWithQuery as the second parameter, takes a string from an Observable source and returns an observable result of T

param

The string to send to the query method

Type parameters

  • T

    The response from an API which returns the result of a query

Type declaration

    • (query: string): ObservableInput<T>
    • Parameters

      • query: string

      Returns ObservableInput<T>

RxJS Boolean Validation Functions

luhnCheck

  • luhnCheck(): OperatorFunction<string | number, boolean>
  • The luhnCheck operator is used to validate identification numbers such as bank cards, IMEI numbers using the Luhn Algorithm

    example

    fromString('4485275742308327') .pipe(luhnCheck()) .subscribe(console.log) // true

    Returns OperatorFunction<string | number, boolean>

    Boolean value if the passed value passes the Luhn check

RxJS Observable Utilities Functions

debounceWithQuery

  • debounceWithQuery<T>(time: number, queryMethod: QueryMethod<T>): OperatorFunction<string, T>
  • Operator that takes an Observable string value and debounces it by the time parameter, and checks that the value changes. When the debounce completes the queryMethod is called and the result returned.

    example
    const doQuery = (query: string) => http.get(`/search?query=${query}`)
    
    fromEvent(input, 'keyup')
     .pipe(debounceWithQuery(500, doQuery))
     .subscribe(console.log)

    Type parameters

    • T

      The response from an API which returns the result of a query

    Parameters

    • time: number

      The time to debounce the query by

    • queryMethod: QueryMethod<T>

      The method that returns the search

    Returns OperatorFunction<string, T>

    An Observable value of T

startWithTap

  • startWithTap<T>(callback: CallbackFn): MonoTypeOperatorFunction<T>
  • Operator that is only executed on the first emission from an Observable The operator is passed a callback which is then executed

    remarks

    This is similar to the tap operator but is only executed once

    example
    form.valueChange.pipe(
     startWithTap(() => this.onTouch())
    ).subscribe()

    Type parameters

    Parameters

    • callback: CallbackFn

      The callback to be executed when this operator is run

    Returns MonoTypeOperatorFunction<T>

    An Observable value of T

tapOnSubscribe

  • tapOnSubscribe<T>(callback: CallbackFn): MonoTypeOperatorFunction<T>
  • Operator that is executed on each subscription to an Observable The operator is passed a callback which is then executed

    remarks

    This is similar to the tap operator but fires when a subscription occurs

    example
    fromEvent(element, 'click').pipe(
     tapOnSubscribe(() => console.log('New Subscription'))
    ).subscribe()

    Type parameters

    Parameters

    • callback: CallbackFn

      The callback to be executed when this operator is run

    Returns MonoTypeOperatorFunction<T>

    An Observable value of T

Generated using TypeDoc