Skip to main content

Home > blockly > Connection

Connection class

Class for a connection between blocks.

Signature:

export declare class Connection 

Constructors

ConstructorModifiersDescription
(constructor)(source, type)Constructs a new instance of the Connection class

Properties

PropertyModifiersTypeDescription
CAN_CONNECTstaticnumberConstants for checking whether two connections are compatible.
idstringThe unique ID of this connection.
REASON_CHECKS_FAILEDstaticnumber
REASON_DIFFERENT_WORKSPACESstaticnumber
REASON_DRAG_CHECKS_FAILEDstaticnumber
REASON_PREVIOUS_AND_OUTPUTstaticnumber
REASON_SELF_CONNECTIONstaticnumber
REASON_SHADOW_PARENTstaticnumber
REASON_TARGET_NULLstaticnumber
REASON_WRONG_TYPEstaticnumber
sourceBlock_protectedBlock
targetConnectionConnection | nullConnection this connection connects to. Null if not connected.
typenumber

Methods

MethodModifiersDescription
connect_(childConnection)protectedConnect 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)protectedDisconnect two blocks that are connected by this connection.
getCheck()Get a connection's compatibility.
getConnectionForOrphanedConnection(startBlock, orphanConnection)staticReturns the connection (starting at the startBlock) which will accept the given connection. This includes compatible connection types and connection checks.
getParentAndChildConnections()protectedReturns 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_()protectedFunction 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_()protectedRespawn 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.