ManagedService
Services contain data and logic that are not related to a particular activity or view.
class ManagedService abstract
extends
ManagedObject
Managed service base class. Represents a service that can be referenced by other classes using the @service
decorator (or ManagedService.link
method) after registering the object with a known name.
Constructor
(name?: string): ManagedService
.find() static
(name: string): ManagedService
Retrieve the currently active service with given name (case insensitive).
Note: Services may be registered and destroyed. To obtain a reference that is always up to date, use the @service
decorator on a class property or the static link
method.
.link() static
(serviceName: string, TargetClass: Function, propertyName: string): void
Adds a property to the prototype of given class, so that the property always references the last registered service with given name (case insensitive).
The value of the target property becomes undefined when the service is destroyed, and updates immediately when a new service is registered with the same name.
Note: Changes and events can be observed by an observer, but only after the property has been read at least once.
.name abstract
string
The name of this service, set only once by the service constructor. The preferred format for service names is Namespace.CamelCaseName
.
.register()
(): this
Register this service, making it available through properties decorated with the @service
decorator until the service object is destroyed (either directly using .destroyManagedAsync()
, or when another service is registered with the same name).
.managedId
number
Inherited from ManagedObject.managedId
.
.managedState
Inherited from ManagedObject.managedState
.
.getReferenceCount() protected
(): number
Inherited from ManagedObject.getReferenceCount
.
.getManagedReferrers() protected
():
ManagedObject
[]
Inherited from ManagedObject.getManagedReferrers
.
.getManagedParent() protected
<TParent extends ManagedObject = ManagedObject>(ParentClass?:
ManagedObjectConstructor
<TParent>): TParent
Inherited from ManagedObject.getManagedParent
.
.emit()
<TEvent extends ManagedEvent = ManagedEvent, TConstructorArgs extends any[] = any[]>(e: string | TEvent | (new (...args: TConstructorArgs) => TEvent), ...constructorArgs: TConstructorArgs): this
Inherited from ManagedObject.emit
.
.emitChange()
(name?: string): void
Inherited from ManagedObject.emitChange
.
.propagateChildEvents() protected deprecated
(...types: ((new (...args: any[]) =>
ManagedEvent
) | ((e:
ManagedEvent
) => any))[]): this
Inherited from ManagedObject.propagateChildEvents
.
.activateManagedAsync() protected
(): Promise<any>
Inherited from ManagedObject.activateManagedAsync
.
.deactivateManagedAsync() protected
(): Promise<void>
Inherited from ManagedObject.deactivateManagedAsync
.
.destroyManagedAsync() protected
(): Promise<void>
Inherited from ManagedObject.destroyManagedAsync
.
.onManagedStateActivatingAsync() protected
(): Promise<void>
Inherited from ManagedObject.onManagedStateActivatingAsync
.
.onManagedStateActiveAsync() protected
(): Promise<void>
Inherited from ManagedObject.onManagedStateActiveAsync
.
.onManagedStateDeactivatingAsync() protected
(): Promise<void>
Inherited from ManagedObject.onManagedStateDeactivatingAsync
.
.onManagedStateInactiveAsync() protected
(): Promise<void>
Inherited from ManagedObject.onManagedStateInactiveAsync
.
.onManagedStateDestroyingAsync() protected
(): Promise<void>
Inherited from ManagedObject.onManagedStateDestroyingAsync
.