Docs (4.0.0)
Services

class ServiceContext

A container of named services, part of the global application context.

class ServiceContext
extends ManagedObject

Description

This class is a container for named services, which should be accessible by the rest of the application. Services can be set, unset, and replaced using the global service context.

  • Use the add() method to add or update a service by ID. The service must be an instance of Service with a valid id property. The service is automatically attached to the ServiceContext instance. An alias of this method is available as app.addService().
  • Use the get() method to retrieve a service by ID, if one is currently registered.
  • Unlink a service to remove (unregister) it.
  • Use the Activity.observeService() or Service.observeService() methods to observe a particular service by ID and handle change events.

Instance Members

  • get(id)Returns a single service instance by ID, if registered.
  • getAll()Returns an array of all currently registered services.
  • add(service)Adds the specified service.
  • clear()Removes all services that are currently registered.

Inherited Members