Skip to content

Commit

Permalink
fix(editor): return copy of array in getNodes/getConnections
Browse files Browse the repository at this point in the history
Improve DX for cases like removing all connections/nodes by iterating them.
  • Loading branch information
Ni55aN committed Jul 24, 2023
1 parent f77e567 commit 369e85e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ export class NodeEditor<Scheme extends BaseSchemes> extends Scope<Root<Scheme>>

/**
* Get all nodes
* @returns All nodes
* @returns Copy of array with nodes
*/
public getNodes() {
return this.nodes
return this.nodes.slice()
}

/**
* Get all connections
* @returns All connections
* @returns Copy of array with onnections
*/
public getConnections() {
return this.connections
return this.connections.slice()
}

/**
Expand Down

0 comments on commit 369e85e

Please sign in to comment.