Class: Connection

saij/connection/Connection~Connection


import Connection from 'saij/connection/Connection';

A connection is an abstract base class to build module:saij/connection/ConnectionTypes from.

A Connection will connect the inputs and outputs of two connectable objects together. For an object to be connectable it must have getInput and getOutput functions that return a module:saij/core/Object~BaseObject. A connection will set listeners on the inputs and output that match up, and forward them on to each other.

new Connection(connectionKey, source, destination)

src/saij/connection/Connection.js, line 85
Name Type Description
connectionKey module:saij/connection/Connection~ConnectionKey

connection key

source module:saij/connection/Connection~Connectable

forward connectable object

destination module:saij/connection/Connection~Connectable

reverse connectable object

connectionKey.id string
connectionKey.type module:saij/connection/ConnectionType
source.getInput function

returns module:saij/core/Object~BaseObject

source.getOutput function

returns module:saij/core/Object~BaseObject

destination.getInput function

returns module:saij/core/Object~BaseObject

destination.getOutput function

returns module:saij/core/Object~BaseObject

Methods

connect(){module:saij/core/Collection~Collection.<module:saij/core/utils/events~EventsKey>}

src/saij/connection/Connection.js, line 193

Connect source to destination in the way described by the type.

Returns:
listeners

disconnect(){Boolean}

src/saij/connection/Connection.js, line 219

Disconnect the connection and clear it's listeners.

Returns:
true if disconnected

getKey(){module:saij/connection/Connection~ConnectionKey}

src/saij/connection/Connection.js, line 271

Get the connection key.

Returns:
connection key

getListeners(){module:saij/core/Collection~Collection.<module:saij/core/utils/events~EventsKey>}

src/saij/connection/Connection.js, line 280

Get the listeners keys for all the input/output listeners on the connection.

Returns:
connection key

isConnected(){Boolean}

src/saij/connection/Connection.js, line 175

Check the connection is setup.

Returns:
true if connected

isListening(){Boolean}

src/saij/connection/Connection.js, line 184

Check the connection has listeners.

Returns:
true if has listeners

setKey(key){Boolean}

src/saij/connection/Connection.js, line 236

Set the connection key. It is advised to use a module:saij/connection/Connection~ConnectionKey with a unique id, unless you wish to group connections. Changing the key type will trigger a reconnection to occur.

Name Type Description
key

connection key

Name Type Description
id string
type module:saij/connection/ConnectionType
Returns:
true if set the key