* Connect this connection to another connection. * * @param otherConnection Connection to connect to. * @returns Whether the blocks are now connected or not.
(otherConnection: Connection)
| 238 | * @returns Whether the blocks are now connected or not. |
| 239 | */ |
| 240 | connect(otherConnection: Connection): boolean { |
| 241 | if (this.targetConnection === otherConnection) { |
| 242 | // Already connected together. NOP. |
| 243 | return true; |
| 244 | } |
| 245 | |
| 246 | const checker = this.getConnectionChecker(); |
| 247 | if (checker.canConnect(this, otherConnection, false)) { |
| 248 | const existingGroup = eventUtils.getGroup(); |
| 249 | if (!existingGroup) { |
| 250 | eventUtils.setGroup(true); |
| 251 | } |
| 252 | // Determine which block is superior (higher in the source stack). |
| 253 | if (this.isSuperior()) { |
| 254 | // Superior block. |
| 255 | this.connect_(otherConnection); |
| 256 | } else { |
| 257 | // Inferior block. |
| 258 | otherConnection.connect_(this); |
| 259 | } |
| 260 | eventUtils.setGroup(existingGroup); |
| 261 | } |
| 262 | |
| 263 | return this.isConnected(); |
| 264 | } |
| 265 | |
| 266 | /** |
| 267 | * Disconnect this connection. |
no test coverage detected