Options
All
  • Public
  • Public/Protected
  • All
Menu

Module boolean

Index

Type aliases

Other Functions

RxJS Boolean Filters Functions

RxJS Boolean Observables Functions

Type aliases

PredicateFn

PredicateFn<T>: (value: T, value2?: T) => boolean

A predicate function that take a value from filter and returns a boolean based on an equality check

example
const isEvenNumber: PredicateFn<number> = (num: number) => num % 2 === 0
returns

Boolean value

Type parameters

  • T

    The type of the value to do an equality check with

Type declaration

    • (value: T, value2?: T): boolean
    • Parameters

      • value: T
      • Optional value2: T

      Returns boolean

Other Functions

Private scheduleSingleOrArrayBoolean

  • scheduleSingleOrArrayBoolean<T>(input: T | T[], scheduler: SchedulerLike): Observable<boolean>
  • Takes an input of boolean and returns a method that updates an subscriber

    Type parameters

    • T

    Parameters

    • input: T | T[]

      The boolean to subscribe to

    • scheduler: SchedulerLike

    Returns Observable<boolean>

Private Const subscribeToSingleOrArrayBoolean

  • subscribeToSingleOrArrayBoolean<T>(input: T | T[]): (Anonymous function)
  • Takes an input of boolean and returns a method that updates an subscriber

    Type parameters

    • T

    Parameters

    • input: T | T[]

      The boolean to subscribe to

    Returns (Anonymous function)

RxJS Boolean Filters Functions

filterTruthy

  • filterTruthy<T>(): MonoTypeOperatorFunction<T>
  • The filterTruthy operator is used to only return truthy values from an Observable stream of values

    example
    from([true, false, '', 'test', undefined, 0, 1])
     .pipe(filterTruthy())
     .subscribe(console.log) // [true, 'test', 1]

    Type parameters

    • T

      Observable value

    Returns MonoTypeOperatorFunction<T>

    All values that are truthy only

firstTruthy

  • firstTruthy<T>(): MonoTypeOperatorFunction<T>
  • firstTruthy<T>(predicate: (arg: T) => boolean): MonoTypeOperatorFunction<T>
  • The firstTruthy operator is used to get only the first truthy value from an Observable stream of values

    example
    fromBoolean<string | number | boolean>([0, false, '', 1])
     .pipe(firstTruthy())
     .subscribe(console.log) // [ 1 ]

    Type parameters

    • T

      Observable value

    Returns MonoTypeOperatorFunction<T>

    The first truthy boolean value

  • If a predicate function is passed, this will be used to do the equality check

    example
    fromNumber([1, 2, 3, 4])
     .pipe(firstTruthy((value) => value % 2 === 0))
     .subscribe(console.log) // 2
    category

    RxJS Boolean Filters

    Type parameters

    • T

      Observable value

    Parameters

    • predicate: (arg: T) => boolean

      Function to do filtering with

        • (arg: T): boolean
        • Parameters

          • arg: T

          Returns boolean

    Returns MonoTypeOperatorFunction<T>

    The first truthy boolean value

lastTruthy

  • lastTruthy<T>(): MonoTypeOperatorFunction<T>
  • lastTruthy<T>(predicate: PredicateFn<T>): MonoTypeOperatorFunction<T>
  • The lastTruthy operator is used to get only the first truthy value from an Observable stream of values

    example
    fromString(['a', 'b', 'c'])
     .pipe(lastTruthy())
     .subscribe(console.log) // 'c'

    Type parameters

    • T

      Observable value

    Returns MonoTypeOperatorFunction<T>

    The last truthy boolean value

  • If a predicate function is passed, this will be used to do the equality check

    example
    fromNumber([1, 2, 3, 4])
     .pipe(firstTruthy((value) => value % 2 === 0))
     .subscribe(console.log) // 4
    category

    RxJS Boolean Filters

    Type parameters

    • T

      Observable value

    Parameters

    • predicate: PredicateFn<T>

      Function to do filtering with

    Returns MonoTypeOperatorFunction<T>

    The last truthy boolean value

RxJS Boolean Observables Functions

fromBoolean

  • fromBoolean<T>(input: T, scheduler?: SchedulerLike): Observable<boolean>
  • fromBoolean<T>(input: T[], scheduler?: SchedulerLike): Observable<boolean>
  • The fromBoolean operator is used to create an Observable boolean from a passed value or array of values. The operator can be overloaded with types to be used with strings, number or mixed sources

    default

    boolean

    example
    fromBoolean(true)
     .pipe(map(val => !val))
     .subscribe(console.log) // false
    example
    fromBoolean<string>('')
     .subscribe(console.log) // false

    Type parameters

    • T

      The type or types to be used to create boolean values from

    Parameters

    • input: T

      Boolean input to create an Observable from

    • Optional scheduler: SchedulerLike

      The SchedulerLike to use for scheduling the emission of values, and providing a notion of "time"

    Returns Observable<boolean>

    Boolean value from the initial parameters

  • Using fromBoolean with an array of booleans is the same as using the from operator from RxJS

    default

    boolean

    example
    fromBoolean<string>(['', 'foo', '', 'bar'])
     .subscribe(console.log) // [false, true, false, true]
    example
    fromBoolean<string | number>([0, 1, '2.5'])
     .subscribe(console.log) // [false, true, true]
    category

    RxJS Boolean Observables

    Type parameters

    • T

      The type or types to be used to create boolean values from

    Parameters

    • input: T[]

      Boolean Array input to create an Observable from

    • Optional scheduler: SchedulerLike

      The SchedulerLike to use for scheduling the emission of values, and providing a notion of "time"

    Returns Observable<boolean>

    Boolean value from the initial parameters

Generated using TypeDoc