Service Interface
Last updated
Last updated
Both the Client Extensions API services and your application services use the same interface. The service interface consists of the following methods:
Create a method on a service and specify the implementation.
Alternately, create several methods on a service at once by specifying an object consisting of multiple functions:
Call a method on a service. Any extra parameters passed to this method will be sent as arguments to the service method:
Fire an event from a service. Any extra parameters passed to this method will be passed to the callbacks defined by services that listen to this event:
Subscribe a service to an event that is fired by another service (or itself). This method returns a handle that can later be used to remove the listener:
The listen
namespace is the same as the namespace for methods, thus names must be unique across both service methods and events.
Unsubscribe a service from an event:
Parameter
Type
Description
methodName
String
The name of the method to create on your service
implementation
Function
The implementation of the method
Parameters
Type
Description
implementations
Object
An object containing one or more functions to create on this service, where the keys are the names of the functions and the values are the implementations
Parameters
Type
Description
methodName
String
The name of the method to call on the service
Parameters
Type
Description
eventName
String
The name of the event to fire
Parameters
Type
Description
eventName
String
The name of the event to listen for
callback
Function
The function that will be called when the event is fired
Parameters
Type
Description
eventName
String
The name of the event to unsubscribe from
handle
String
The handle returned by the call to listen