Class: ConnectionDB
Defined in: packages/blockly/core/connection_db.ts:26
Database of connections. Connections are stored in order of their vertical component. This way connections in an area may be looked up quickly using a binary search.
Methods index
| Method | Description |
|---|---|
| removeConnection | Remove a connection from the database. Must already exist in DB. |
| reorderConnection | Moves the given connection in the connection DB to reflect its new Y position. For performance, this will be deferred if the connection DB is in the middle of a bulk update. |
| getNeighbours | Find all nearby connections to the given connection. Type checking does not apply, since this function is used for bumping. |
| searchForClosest | Find the closest compatible connection to this connection. |
| init | Initialize a set of connection DBs for a workspace. |
Constructors
Constructor
new ConnectionDB(connectionChecker): ConnectionDB;
Defined in: packages/blockly/core/connection_db.ts:40
Parameters
| Parameter | Type | Description |
|---|---|---|
connectionChecker | IConnectionChecker | The workspace's connection type checker, used to decide if connections are valid during a drag. |
Returns
ConnectionDB
Methods
removeConnection()
removeConnection(connection, yPos): void;
Defined in: packages/blockly/core/connection_db.ts:135
Remove a connection from the database. Must already exist in DB.
Parameters
| Parameter | Type | Description |
|---|---|---|
connection | RenderedConnection | The connection to be removed. |
yPos | number | The y position used to find the index of the connection. |
Returns
void
Throws
If the connection cannot be found in the database.
reorderConnection()
reorderConnection(connection, newYPos): void;
Defined in: packages/blockly/core/connection_db.ts:153
Moves the given connection in the connection DB to reflect its new Y position. For performance, this will be deferred if the connection DB is in the middle of a bulk update.
Parameters
| Parameter | Type | Description |
|---|---|---|
connection | RenderedConnection | The connection that is moving. Should be provided before its Connection.y field has been updated. |
newYPos | number | The y coordinate (in workspace units) to which the connection will move. |
Returns
void
getNeighbours()
getNeighbours(connection, maxRadius): RenderedConnection[];
Defined in: packages/blockly/core/connection_db.ts:168
Find all nearby connections to the given connection. Type checking does not apply, since this function is used for bumping.
Parameters
| Parameter | Type | Description |
|---|---|---|
connection | RenderedConnection | The connection whose neighbours should be returned. |
maxRadius | number | The maximum radius to another connection. |
Returns
List of connections.
searchForClosest()
searchForClosest(
conn,
maxRadius,
dxy
): object;
Defined in: packages/blockly/core/connection_db.ts:247
Find the closest compatible connection to this connection.
Parameters
| Parameter | Type | Description |
|---|---|---|
conn | RenderedConnection | The connection searching for a compatible mate. |
maxRadius | number | The maximum radius to another connection. |
dxy | Coordinate | Offset between this connection's location in the database and the current location (as a result of dragging). |
Returns
object
Contains two properties: 'connection' which is either another connection or null, and 'radius' which is the distance.
connection
connection: RenderedConnection | null;
radius
radius: number;
init()
static init(checker): ConnectionDB[];
Defined in: packages/blockly/core/connection_db.ts:352
Initialize a set of connection DBs for a workspace.
Parameters
| Parameter | Type | Description |
|---|---|---|
checker | IConnectionChecker | The workspace's connection checker, used to decide if connections are valid during a drag. |
Returns
ConnectionDB[]
Array of databases.