Managed reference objects encapsulate references to other managed objects.

Managed objects

This class is part of a group of managed object classes. Read more about Components for details.

See also

ManagedList, ManagedMap, ManagedObject.

class ManagedReference

extends ManagedObject

Independent reference to a managed object, list, map, or other managed reference.

This class can be used to encapsulate references to managed objects, not as a property of another managed object but as a stand-alone ‘reference object’.

Child references

If a managed object property that is decorated with @managedChild gets assigned a ManagedReference instance, the parent-child relationship will extend to the target of this ManagedReference instance. In other words, the target of a ManagedReference that is itself a managed child object, will become a managed child itself.

In this case, changing the target of the ManagedReference object will destroy the previously referenced object.


<T extends ManagedObject = ManagedObject>(target?: T): ManagedReference<T>


[1]. (f?: (this: this, e: ManagedEvent) => void | ManagedEvent | ManagedEvent[]): this
[2]. (...types: (ManagedEvent | (new (...args: any[]) => ManagedEvent))[]): this

[1] Propagate events from referenced objects by emitting them on the reference instance itself, optionally restricted to given types of events or a filter function

[2] Propagate events from referenced objects by emitting them on the reference instance itself, optionally restricted to given types of events or a filter function.


<T extends ManagedObject>(classType: ManagedObjectConstructor<T>): ManagedReference<T>

Ensure that referenced object is an instance of given class (or a sub class), and restrict new references to instances of given class. Given class must be a sub class of ManagedObject.


(): T

Returns the referenced object, or undefined.



The referenced object, or undefined.


(): this

Remove the current reference, if any.


(target?: T): this

Set the current reference to given object, or managed list, map, or another reference. Equivalent to setting the target property on this instance.


(): this

Stop newly referenced objects from becoming child objects even if this ManagedReference instance itself is held through a child reference (by a parent object); this can be used to automatically dereference objects when the parent object is destroyed.


(): { "$ref": number; }

Returns the referenced object itself, or undefined (alias of get() method).



Inherited from ManagedObject.managedId.



Inherited from ManagedObject.managedState.

.getReferenceCount() protected

(): number

Inherited from ManagedObject.getReferenceCount.

.getManagedReferrers() protected

(): ManagedObject[]

Inherited from ManagedObject.getManagedReferrers.

.getManagedParent() protected

[1]. (): ManagedObject
[2]. <TParent extends ManagedObject>(ParentClass: ManagedObjectConstructor<TParent>): TParent

Inherited from ManagedObject.getManagedParent.


<TEvent extends ManagedEvent = ManagedEvent, TConstructorArgs extends any[] = any[]>(e: string | TEvent | (new (...args: TConstructorArgs) => TEvent), ...constructorArgs: TConstructorArgs): this

Inherited from ManagedObject.emit.

.propagateChildEvents() protected

[1]. (f?: (this: this, e: ManagedEvent, propertyName: string) => void | ManagedEvent | ManagedEvent[]): this
[2]. (...types: (ManagedEvent | (new (...args: any[]) => ManagedEvent))[]): 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.