MCPcopy
hub / github.com/RaspberryPiFoundation/blockly / reconnect

Method reconnect

packages/blockly/core/connection.ts:360–379  ·  view source on GitHub ↗

* Reconnects this connection to the input with the given name on the given * block. If there is already a connection connected to that input, that * connection is disconnected. * * @param block The block to connect this connection to. * @param inputName The name of the input to connec

(block: Block, inputName: string)

Source from the content-addressed store, hash-verified

358 * @returns True if this connection was able to connect, false otherwise.
359 */
360 reconnect(block: Block, inputName: string): boolean {
361 // No need to reconnect if this connection's block is deleted.
362 if (this.getSourceBlock().isDeadOrDying()) return false;
363
364 const connectionParent = block.getInput(inputName)?.connection;
365 const currentParent = this.targetBlock();
366 if (
367 (!currentParent || currentParent === block) &&
368 connectionParent &&
369 connectionParent.targetConnection !== this
370 ) {
371 if (connectionParent.isConnected()) {
372 // There's already something connected here. Get rid of it.
373 connectionParent.disconnect();
374 }
375 connectionParent.connect(this);
376 return true;
377 }
378 return false;
379 }
380
381 /**
382 * Returns the block that this connection connects to.

Callers 5

text.tsFile · 0.80
lists.tsFile · 0.80
procedures.tsFile · 0.80
logic.tsFile · 0.80
blocks.jsFile · 0.80

Calls 7

getSourceBlockMethod · 0.95
targetBlockMethod · 0.95
getInputMethod · 0.80
isConnectedMethod · 0.80
disconnectMethod · 0.80
connectMethod · 0.80
isDeadOrDyingMethod · 0.45

Tested by

no test coverage detected