Editor.ScopedConnection
ClassStores event listener connections, automatically cleaned up on scope exit.
Index
Properties
Methods
Example
// ScopedConnection is the handle returned by signal.connect(). Store it
// for the lifetime you want the handler to stay active — disconnect() in
// stop() to cleanly detach when the plugin unloads.
const model = this.pluginSystem.findInterface(Editor.Model.IModel) as Editor.Model.IModel;
// onProjectChanged fires when switching projects; onProjectSaving fires
// after a save completes (use it to react to Save As landing on disk).
const changedConn: Editor.ScopedConnection = model.onProjectChanged.connect(() => {
console.log('switched to a new project');
});
const savingConn: Editor.ScopedConnection = model.onProjectSaving.connect(
(mode: Editor.Model.ProjectSaveMode) => {
console.log(`project saved, mode=${mode}`);
}
);
// Retain both connections so they are not garbage-collected while alive.
this.connections.push(changedConn, savingConn);
console.log(`Active connections: ${this.connections.filter(c => c.isConnected).length}`);
Extends
Properties
isConnected
readonlyisConnected:boolean
Indicates whether the connection is currently active.
Methods
disconnect()
disconnect():
boolean
Disconnects the associated signal connection and returns true if it was active.
Returns
boolean
dispose()
dispose():
void
Free the guarded resource immediately.
Returns
void
Inherited from
getTypeName()
staticgetTypeName():string
Returns the type name of this class.
Returns
string
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object is of the specified type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object refers to the same instance as the given object.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean