Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Context

Application context representation class - a hosting environment for application or its sub context TODO: Add handling of child and parent contexts in this class

author

Jānis Radiņš

Hierarchy

Index

Constructors

Private constructor

Properties

injector

injector: Injector = new Injector()

Injector instance used within current Context

type

{Injector}

Accessors

destroyed

  • get destroyed(): boolean

initialized

  • get initialized(): boolean
  • Whether Context is initialized. Extension mappings and modules should be added only whilst Context is not initialized.

    Returns boolean

listenerCount

  • get listenerCount(): number

Methods

addEventListener

  • Add event listener.

    Parameters

    • event: string

      Event name for which to listen to

    • listener: EventListener

      Listener function that will be invoked as event with specified name is dispatched.

    • Optional scope: Object

      Listener scope which will be applied as listener is invoked. (You can leave it undefined, if you don't care about scope that much).

    Returns EventMapping

    Null in case if event name is already mapped to same function. Or EventMapping object which is to be used in order to set some of mapping properties like once() which will make listener to be executed upon first event dispatch and then be gone.

configure

  • configure(...module: Array<any>): this
  • Configure application with application modules.

    Parameters

    • Rest ...module: Array<any>

      A single entry or list of modules demarcated by @Module decorator.

    Returns this

    Current context operation is performed on

destroy

  • destroy(): void

Private dispatchEvent

  • dispatchEvent(event: Event): boolean
  • dispatchEvent(eventType: string, eventData?: any): boolean

Protected dispatchEventImpl

  • dispatchEventImpl(event: Event): boolean

hasEventListener

  • hasEventListener(event: string, listener?: EventListener, scope?: Object): boolean

hasModule

  • hasModule(module: Type<any>): boolean
  • Check if some module is mapped with Context via direct mapping via configure() call or as required module of any directly mapped modules. This method will return any valid data only after Context is initialized

    Parameters

    • module: Type<any>

      Module to check mapping of

    Returns boolean

initialize

  • initialize(): void
  • Initialize context - install extensions, map modules and move through init lifecycle phases

    throws

    Error on repeated call

    Returns void

install

  • install(...extension: Array<any>): this
  • Install Context extensions or

    Parameters

    • Rest ...extension: Array<any>

      A single entry or list of Type entries

    Returns this

    Current context operation is performed on

listenOnce

  • Add event listener that will be executed only once.

    Parameters

    • event: string

      Event name for which to listen to

    • listener: EventListener

      Listener function that will be invoked as event with specified name is dispatched.

    • Optional scope: Object

      Listener scope which will be applied as listener is invoked. (You can leave it undefined, if you don't care about scope that much).

    Returns EventMapping

    Null in case if event name is already mapped to same function. Or EventMapping object which is to be used in order to set some of mapping properties like once() which will make listener to be executed upon first event dispatch and then be gone.

removeAllEventListeners

  • removeAllEventListeners(scope?: Object): boolean
  • Remove all listeners registered with specified scope or with the whole dispatcher instance.

    Parameters

    • Optional scope: Object

      Scope from which all listeners mapped listeners will be removed. If not specified, all listeners will be removed from whole dispatcher instance.

    Returns boolean

    True if any listeners to remove where found; false otherwise.

removeEventListener

  • removeEventListener(event: string, listener: EventListener, scope?: Object): boolean

removeEventListeners

  • removeEventListeners(eventType: string, scope?: Object): boolean
  • Remove all listeners of a particular event from all scopes or the specified scope.

    Parameters

    • eventType: string

      Event name to be unmapped from all listeners.

    • Optional scope: Object

      Listener scope from which all listeners mapped to eventType will be removed.

    Returns boolean

    True if any of mappings have been found; false otherwise.