Options
All
  • Public
  • Public/Protected
  • All
Menu

Module api/operators

RxJS operators.

This module defines RxJS operators specific for Z-Bus usage.

Index

Functions

Functions

receive

  • receive(address?: number | number[], command?: number | keyof typeof Command | (number | keyof typeof Command)[]): UnaryFunction<Observable<DeviceEvent>, Observable<DeviceEvent>>
  • Filter DeviceEvents emitted by the source Observable by only this address and/or event

    Example

    const { receive } = require('@z-bus/api/operators');
    zBus.reception.pipe(receive(80)).subscribe((event) => {
      console.log('Received', event.event, 'on address 80');
    });
    

    Parameters

    • Optional address: number | number[]

      If an emitted DeviceEvent matches this address (or one of these addresses), it is passed on, and filtered otherwise

    • Optional command: number | keyof typeof Command | (number | keyof typeof Command)[]

      If an emitted DeviceEvent matches this event (or one of these commands), it is passed on, and filtered otherwise

    Returns UnaryFunction<Observable<DeviceEvent>, Observable<DeviceEvent>>

transmit

  • transmit(address?: number | number[], command?: number | Command, data?: number[]): UnaryFunction<Observable<DeviceEvent>, Observable<DeviceEvent>>
  • Perform a side transmission for every emission on the source DeviceEvent, but return an DeviceEvent that is identical to the source.

    Example

    This implements an automatic staircase timer by using receive, transmit, and the RxJS debounceTime operator.

    const { receive, transmit } = require('@z-bus/api/operators');
    const { debounceTime } = require('rxjs/operators');
    zBus.reception
      .pipe(
         receive(99), // when 99 is triggered
         transmit(99, 'on'), // then switch 99 on
         debounceTime(3 * 60 * 1000), // debounce for 3 minutes
         transmit(99, 'off') // and switch 99 off (after 3 minutes of silence)
      )
      .subscribe();
    

    Parameters

    • Optional address: number | number[]

      One or more addresses of the controlled Device(s) between 0 and 242

    • Optional command: number | Command

      Valid Command (name or number between 0 and 255) to send to the device

    • Optional data: number[]

      An optional two-bytes data packet.

    Returns UnaryFunction<Observable<DeviceEvent>, Observable<DeviceEvent>>

Generated using TypeDoc