Options
All
  • Public
  • Public/Protected
  • All
Menu

An EventHandler is a generic class that enables subscription, unsubscription to an event

description

Declare an event as a property in your class like this

public class MyCLass {
    public EventHandler<string> someEvent = new EventHandler<string>();
}

Subscribe to the event like this

const myClass = new MyClass();
myClass.subscribe((event) => {
   console.log(event);
});

Publish an event like this

const myClass = new MyClass();
myClass.raiseEvent("Hi there!");

Type parameters

  • T

Hierarchy

  • IEventHandler

Implemented by

Index

Methods

subscribe

  • subscribe(handler: (data?: T) => void): void
  • Subscribes to the event

    Parameters

    • handler: (data?: T) => void
        • (data?: T): void
        • Parameters

          • Optional data: T

          Returns void

    Returns void

unsubscribe

  • unsubscribe(handler: (data?: T) => void): void
  • Unsubscribes from the event

    Parameters

    • handler: (data?: T) => void
        • (data?: T): void
        • Parameters

          • Optional data: T

          Returns void

    Returns void

Generated using TypeDoc