Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PubSub<T>

Type parameters

  • T

Hierarchy

  • PubSub

Implements

Index

Constructors

constructor

Properties

Protected fn

fn: TopicFn<T>

Protected src

src: Channel<T>

Protected topics

topics: IObjectOf<Mult<T>>

Protected Static NEXT_ID

NEXT_ID: number = 0

Accessors

id

  • get id(): string
  • set id(id: string): void

Methods

channel

close

  • close(flush?: boolean): undefined | Promise<void>

Protected process

  • process(): Promise<void>

sub

  • sub(id: string, tx?: Transducer<T, any>): undefined | Channel<any>
  • Creates a new topic subscription channel and returns it. Each topic is managed by its own Mult and can have arbitrary number of subscribers. If the optional transducer is given, it will only be applied to the new subscription channel.

    The special "*" topic can be used to subscribe to all messages and acts as multiplexed pass-through of the source channel.

    Parameters

    • id: string

      topic id

    • Optional tx: Transducer<T, any>

      transducer for new subscription

    Returns undefined | Channel<any>

unsub

  • unsub(id: string, ch: Channel<T>): boolean

unsubAll

  • unsubAll(id: string, close?: boolean): boolean

write

  • write(val: any): Promise<boolean>

Generated using TypeDoc