Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CommandMap

Event command map describes event name to command class mappings and is useful as small pieces of control code should be executed upon some event notification.

author

Jānis Radiņš / Kristaps Peļņa

Hierarchy

  • CommandMap

Index

Properties

Protected injector

injector: Injector

Accessors

mappingCount

  • get mappingCount(): number

Methods

Protected createCommandInstance

map

  • Map event notification to a command class.

    Parameters

    • eventType: string

      String event name which will tiger execution of a command.

    • command: Type<Command>

      Command class which should implement Command interface or, at least, should have execute method defined with same signature.

    Returns CommandMapping

    data object which describes mapping and can be used to set command execution only once; or null in case if mapping of requested event type is already mapped to class instance.

Private trigger

  • trigger(event: Event): void | Error
  • trigger(eventType: string, eventData?: any): void | Error
  • Trigger all commands which are mapped to this event.

    Parameters

    • event: Event

      Event object that defines event type and data

    Returns void | Error

  • Trigger all commands which are mapped to event name.

    Parameters

    • eventType: string

      String event name commands mapped to which must be invoked.

    • Optional eventData: any

      Arbitrary data to be passed along with command invocation.

    Returns void | Error

Private unMap

  • unMap(): boolean
  • unMap(eventType: string): boolean
  • unMap(eventType: string, command: Type<Command>): boolean
  • Remove all command mappings from all event type.

    Returns boolean

    which indicates if the unMapping has been successful.

  • Remove all command mappings for the specified event type.

    Parameters

    • eventType: string

      Event name which is mapped to a command.

    Returns boolean

    which indicates if the unMapping has been successful.

  • Remove event type to command mapping.

    Parameters

    • eventType: string

      Event name which is mapped to a command.

    • command: Type<Command>

      Event command class which should be unmapped.

    Returns boolean

    which indicates if the unMapping has been successful.