ASP.NET Core MVC Controls | ComponentOne
In This Topic
    Event Class
    In This Topic
    File
    wijmo.js
    Module
    wijmo

    Represents an event.

    Wijmo events are similar to .NET events. Any class may define events by declaring them as fields. Any class may subscribe to events using the event's addHandler method and unsubscribe using the removeHandler method.

    Wijmo event handlers take two parameters: sender and args. The first is the object that raised the event, and the second is an object that contains the event parameters.

    Classes that define events follow the .NET pattern where for every event there is an on[EVENTNAME] method that raises the event. This pattern allows derived classes to override the on[EVENTNAME] method and handle the event before and/or after the base class raises the event. Derived classes may even suppress the event by not calling the base class implementation.

    For example, the TypeScript code below overrides the onValueChanged event for a control to perform some processing before and after the valueChanged event fires:

    // override base class
    onValueChanged(e: EventArgs) {
    
      // execute some code before the event fires
      console.log('about to fire valueChanged');
    
      // optionally, call base class to fire the event
      super.onValueChanged(e);
    
      // execute some code after the event fired
      console.log('valueChanged event just fired');
    }
    

    Constructor

    Properties

    Methods

    Constructor

    constructor

    constructor(handlersChanged?: Function): Event
    

    Initializes a new instance of an Event.

    Parameters
    Optional

    Optional callback invoked when handlers are added or removed from this Event.

    Returns
    Event

    Properties

    handlerCount

    Gets the number of handlers added to this event.

    Type
    number

    hasHandlers

    Gets a value that indicates whether this event has any handlers.

    Type
    boolean

    Methods

    addHandler

    addHandler(handler: IEventHandler, self?: any): void
    

    Adds a handler to this event.

    Parameters
    • handler: IEventHandler

      Function invoked when the event is raised.

    • self: any
    Optional

    Object that defines the event handler (accessible as 'this' from the handler code).

    Returns
    void

    getHandler

    getHandler(index?: number): IEventHandler
    

    Gets a handler to this event.

    Parameters
    Optional

    Desired handle index number, this is usually zero.

    Returns
    IEventHandler

    raise

    raise(sender: any, args?: EventArgs): void
    

    Raises this event, causing all associated handlers to be invoked.

    Parameters
    • sender: any

      Source object.

    • args: EventArgs Optional

      Event parameters.

    Returns
    void

    removeAllHandlers

    removeAllHandlers(): void
    

    Removes all handlers associated with this event.

    Returns
    void

    removeHandler

    removeHandler(handler: IEventHandler, self?: any): void
    

    Removes a handler from this event.

    Parameters
    • handler: IEventHandler

      Function invoked when the event is raised.

    • self: any Optional

      Object that owns the event handler (accessible as 'this' from the handler code).

    Returns
    void