Options
All
  • Public
  • Public/Protected
  • All
Menu

Encapsulates an event object, in order to hide its methods emit and cancelAll, so the event consumer can only receive the event, but cannot emit it, or cancel other subscriptions.

It is a non-extendable class, with the same signature as SubEvent, minus methods emit and cancelAll.

// Example of using EventConsumer inside a component.

import {SubEvent, EventConsumer} from 'sub-events';

class MyComponent {

    private event: SubEvent<string> = new SubEvent(); // internal, send-receive event

    readonly safeEvent: EventConsumer<string>; // public, receive-only event container

    constructor() {
       this.safeEvent = new EventConsumer(this.event);

       // or even simpler:
       // this.safeEvent = this.event.toConsumer();

       // clients can only receive data from such "safeEvent",
       // they cannot emit data or cancel other subscriptions.
    }
}

Type parameters

Hierarchy

  • EventConsumer

Index

Constructors

Accessors

Methods

Constructors

constructor

Accessors

count

  • get count(): number

maxSubs

  • get maxSubs(): number

Methods

getStat

once

subscribe

toPromise

  • toPromise(options?: {}): Promise<T>

Legend

  • Property
  • Method
  • Property
  • Inherited method

Generated using TypeDoc