Samsung Electronics logo

Using the Generic Event Handlers



Learning how to use generic, predefined event handlers allows you handle application operations and errors efficiently:

  1. The generic onSuccess() event handler of the SuccessCallBack interface can be used with methods that do not require a return value when successful.

    In this example, the event handler is used to stop a running application with the kill() method of the Application interface.

    function onSuccess() 
    {
       console.log("Application terminated successfully");
    }
    
    webapis.application.kill(appIDToKill, onSuccess);
  2. The generic onError() event handler of the ErrorCallBack interface can be used with methods that only require an error as an input parameter in the error callback.

    In this example, the event handler is used to handle possible errors with the getCalendars() method of the CalendarManager interface.

    function errorCallback(error)
    {
       console.log("The following error occurred: " + error.name);
    }
    
    webapis.calendar.getCalendars("EVENT", calendarListCallback, errorCallback);