blockly > Connection

Connection class

Class for a connection between blocks.

Signature:

export declare class Connection implements IASTNodeLocationWithBlock 

Implements: IASTNodeLocationWithBlock

Constructors

Constructor Modifiers Description
(constructor)(source, type) Constructs a new instance of the Connection class

Properties

Property Modifiers Type Description
CAN_CONNECT static number Constants for checking whether two connections are compatible.
REASON_CHECKS_FAILED static number
REASON_DIFFERENT_WORKSPACES static number
REASON_DRAG_CHECKS_FAILED static number
REASON_PREVIOUS_AND_OUTPUT static number
REASON_SELF_CONNECTION static number
REASON_SHADOW_PARENT static number
REASON_TARGET_NULL static number
REASON_WRONG_TYPE static number
sourceBlock_ protected Block
targetConnection Connection | null Connection this connection connects to. Null if not connected.
type number

Methods

Method Modifiers Description
connect_(childConnection) protected Connect two connections together. This is the connection on the superior block.
connect(otherConnection) Connect this connection to another connection.
disconnect() Disconnect this connection.
disconnectInternal(setParent) protected Disconnect two blocks that are connected by this connection.
getCheck() Get a connection's compatibility.
getConnectionForOrphanedConnection(startBlock, orphanConnection) static Returns the connection (starting at the startBlock) which will accept the given connection. This includes compatible connection types and connection checks.
getParentAndChildConnections() protected Returns the parent connection (superior) and child connection (inferior) given this connection and the connection it is connected to.
getShadowDom(returnCurrent) Returns the xml representation of the connection's shadow block.
getShadowState(returnCurrent) Returns the serialized object representation of the connection's shadow block.
getSourceBlock() Get the source block for this connection.
isConnected() Is the connection connected?
isSuperior() Does the connection belong to a superior block (higher in the source stack)?
onCheckChanged_() protected Function to be called when this connection's compatible types have changed.
reconnect(block, inputName) 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.
respawnShadow_() protected Respawn the shadow block if there was one connected to the this connection.
setCheck(check) Change a connection's compatibility.
setShadowDom(shadowDom) Changes the connection's shadow block.
setShadowState(shadowState) Changes the connection's shadow block.
targetBlock() Returns the block that this connection connects to.
toString() This method returns a string describing this Connection in developer terms (English only). Intended to on be used in console logs and errors.