class Service
An abstract class that represents a named service.
abstract
class Service extends ManagedObject
Description
Services are instances of the Service
class that are made available to the rest of your application by ID, using ServiceContext (available through app.services). Typically, services are observed from activities or other services, and provide shared functionality or data.
To add a service, extend the Service class, create an instance, assign an ID, and add it to the service context using app.addService(). When another service is added with the same ID, the existing service is replaced and unlinked.
Constructor
- constructor()Creates a new managed object.
Instance Members
- isServiceRegistered()Returns true if this service is currently registered.
- id abstractreadonlyThe unique ID for this service (instance).
- observeService(id, observer?) protectedObserves another service by ID, until the current service is unlinked.
Inherited Members
- emit(event)Emits an event, immediately calling all event handlers.
- emitChange(name?, data?)Emits a change event, an instance of ManagedChangeEvent.
- listen(handler)Adds a handler for all events emitted by this object.
- isUnlinked()Returns true if the object has been unlinked.
- unlink()Unlinks this managed object.
- beforeUnlink() protectedA method that’s called immediately before unlinking an object, can be overridden.
- attach(target, observer?) protectedAttaches the provided managed object to this object.
- autoAttach(propertyName, observer?) protectedObserves a property, so that any object assigned to it is attached immediately.
Related
- class ServiceContextA container of named services, part of the global application context.