@@ -108,7 +108,7 @@ export interface IdentifyResult {
108
108
* Event names are `noun:verb` so the first part is the name of the object
109
109
* being acted on and the second is the action.
110
110
*/
111
- export interface Libp2pEvents {
111
+ export interface Libp2pEvents < T extends ServiceMap = ServiceMap > {
112
112
/**
113
113
* This event is dispatched when a new network peer is discovered.
114
114
*
@@ -225,6 +225,28 @@ export interface Libp2pEvents {
225
225
* closed.
226
226
*/
227
227
'connection:close' : CustomEvent < Connection >
228
+
229
+ /**
230
+ * This event notifies listeners that the node has started
231
+ *
232
+ * ```js
233
+ * libp2p.addEventListener('start', (event) => {
234
+ * console.info(libp2p.isStarted()) // true
235
+ * })
236
+ * ```
237
+ */
238
+ 'start' : CustomEvent < Libp2p < T > >
239
+
240
+ /**
241
+ * This event notifies listeners that the node has stopped
242
+ *
243
+ * ```js
244
+ * libp2p.addEventListener('stop', (event) => {
245
+ * console.info(libp2p.isStarted()) // false
246
+ * })
247
+ * ```
248
+ */
249
+ 'stop' : CustomEvent < Libp2p < T > >
228
250
}
229
251
230
252
/**
@@ -281,7 +303,7 @@ export interface PendingDial {
281
303
/**
282
304
* Libp2p nodes implement this interface.
283
305
*/
284
- export interface Libp2p < T extends ServiceMap = Record < string , unknown > > extends Startable , EventEmitter < Libp2pEvents > {
306
+ export interface Libp2p < T extends ServiceMap = ServiceMap > extends Startable , EventEmitter < Libp2pEvents < T > > {
285
307
/**
286
308
* The PeerId is a unique identifier for a node on the network.
287
309
*
0 commit comments