You are here

Events

Events are fired on completion of certain operations.

The general approach used in the SkyVault Appcelerator SDK is to rely on event handlers. When a operation is carried out, certain events may be fired, and these can be processed via event handlers. Event handlers are registered to handle specific events. The event types available depend on the service concerned. For example, the DocumentFolderService supports the following events:

  • error
  • retrievedfolder
  • documentnode
  • foldernode
  • pagingresult
  • endenumeration
  • progresseddocument
  • retrieveddocument
  • newdocumentnode
  • newfoldernode
  • deletednode
  • retrievedisfavorite
  • addedfavorite
  • removedfavorite

Event handlers can be registered for each event type of interest in the following manner:

        
var documentFolderService = SDKModule.createDocumentFolderService();

documentFolderService.addEventListener('error', function(e) { alert(e.errorstring); });

documentFolderService.initialiseWithSession (repoSession);

documentFolderService.addEventListener('retrievedfolder', function(e)
{

    documentFolderService.addEventListener('documentnode', function(e) { var doc = e.document; ... });

    documentFolderService.addEventListener('foldernode', function(e) { var folder = e.folder; ... });

    documentFolderService.retrieveChildrenInFolder();

}); 

documentFolderService.retrieveRootFolder();

        
      

In this example an event handler is attached to the retrievedfolder event. This event handler in turn registers event handlers for documentnode and foldernode events, will could be fired after the call to retrieveChildrenInFolder().

Note, the event object passed into the event handler (e in the previous code) depends on the event type. If you register an event handler on documentnode for example, you will get back a documentnode event object. Each event object has certain properties that can be accessed, and these are all documented in the API reference. For example, the documentnode event object has a document property (of type Document).