Skip to main content

Editor.IGuard

Class

Represents ownership of a resource.

Represents ownership of a resource. If this object is garbage collected, or dispose() method is called – the associated resource is freed.

Index

Example

// IGuard represents ownership of a registered resource.
// Store the guard and call dispose() in stop() to unregister cleanly.
const registry = this.pluginSystem.findInterface(
Editor.IContextActionRegistry.interfaceId
) as Editor.IContextActionRegistry;
if (Editor.isNull(registry)) {
console.log('IContextActionRegistry not available');
return;
}

const guard: Editor.IGuard = registry.registerAction(
(ctx: Editor.IContext) => {
console.log('Context action triggered');
return undefined as unknown as Editor;
}
);
this.guards.push(guard);
console.log('Context action registered, guard stored for cleanup');

Extends

Extended by

Methods

dispose()

dispose(): void

Free the guarded resource immediately.

Returns

void


getTypeName()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

Returns true if this object refers to the same instance as the given object.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame