Optional
peerOptional
peerStatic
prefixedRest
...args: ArgumentMap<NetworkAdapterEvents>[Extract<T, keyof NetworkAdapterEvents>]Optional
context: anyCalled by the Repo to start the connection process
Optional
peerMetadata: PeerMetadatapeerId - the peerId of this repo
peerMetadata - how this adapter should present itself to other peers
Called by the Repo to disconnect from the network
Calls each of the listeners registered for a given event.
Rest
...args: ArgumentMap<NetworkAdapterEvents>[Extract<T, keyof NetworkAdapterEvents>]Return an array listing the events for which the emitter has registered listeners.
Return the number of listeners listening to a given event.
Return the listeners registered for a given event.
Optional
fn: ((...args) => void)Rest
...args: ArgumentMap<NetworkAdapterEvents>[Extract<T, keyof NetworkAdapterEvents>]Optional
context: anyOptional
once: booleanAdd a listener for a given event.
Rest
...args: ArgumentMap<NetworkAdapterEvents>[Extract<T, keyof NetworkAdapterEvents>]Optional
context: anyAdd a one-time listener for a given event.
Rest
...args: ArgumentMap<NetworkAdapterEvents>[Extract<T, keyof NetworkAdapterEvents>]Optional
context: anyRemove the listeners of a given event.
Optional
fn: ((...args) => void)Rest
...args: ArgumentMap<NetworkAdapterEvents>[Extract<T, keyof NetworkAdapterEvents>]Optional
context: anyOptional
once: booleanCalled by the Repo to send a message to a peer
message - the message to send
An interface representing some way to connect to other peers
Remarks
The Repo uses one or more
NetworkAdapter
s to connect to other peers. Because the network may take some time to be ready the Repo will wait until the adapter emits aready
event before it starts trying to use itThis utility class can be used as a base to build a custom network adapter. It is most useful as a simple way to add the necessary event emitter functionality