@@ -5,15 +5,17 @@ import { EventEmitter } from "events";
5
5
/**
6
6
* Options is an additional, optional dictionary of options that may
7
7
* be passed to an EmitterFunction and TransportFunction
8
+ * @interface
8
9
*/
9
10
export interface Options {
10
11
[ key : string ] : string | Record < string , unknown > | unknown ;
11
12
}
12
13
13
14
/**
14
- * EmitterFunction is an invokable interface returned by the emitterFactory
15
- * function. Invoke an EmitterFunction with a CloudEvent and optional transport
15
+ * EmitterFunction is an invokable interface returned by { @linkcode emitterFor}.
16
+ * Invoke an EmitterFunction with a CloudEvent and optional transport
16
17
* options to send the event as a Message across supported transports.
18
+ * @interface
17
19
*/
18
20
export interface EmitterFunction {
19
21
( event : CloudEvent , options ?: Options ) : Promise < unknown > ;
@@ -23,18 +25,20 @@ export interface EmitterFunction {
23
25
* TransportFunction is an invokable interface provided to the emitterFactory.
24
26
* A TransportFunction's responsiblity is to send a JSON encoded event Message
25
27
* across the wire.
28
+ * @interface
26
29
*/
27
30
export interface TransportFunction {
28
31
( message : Message , options ?: Options ) : Promise < unknown > ;
29
32
}
30
33
31
34
const emitterDefaults = { binding : HTTP , mode : Mode . BINARY } ;
32
35
/**
33
- * emitterFactory creates and returns an EmitterFunction using the supplied
34
- * TransportFunction. The returned EmitterFunction will invoke the Binding's
35
- * `binary` or `structured` function to convert a CloudEvent into a JSON
36
- * Message based on the Mode provided, and invoke the TransportFunction with
37
- * the Message and any supplied options.
36
+ * Creates and returns an {@linkcode EmitterFunction} using the supplied
37
+ * {@linkcode TransportFunction}. The returned {@linkcode EmitterFunction}
38
+ * will invoke the {@linkcode Binding}'s `binary` or `structured` function
39
+ * to convert a {@linkcode CloudEvent} into a JSON
40
+ * {@linkcode Message} based on the {@linkcode Mode} provided, and invoke the
41
+ * TransportFunction with the Message and any supplied options.
38
42
*
39
43
* @param {TransportFunction } fn a TransportFunction that can accept an event Message
40
44
* @param { {Binding, Mode} } options network binding and message serialization options
@@ -62,7 +66,7 @@ export function emitterFor(fn: TransportFunction, options = emitterDefaults): Em
62
66
}
63
67
64
68
/**
65
- * A static class to emit CloudEvents within an application
69
+ * A helper class to emit CloudEvents within an application
66
70
*/
67
71
export class Emitter {
68
72
/**
@@ -97,7 +101,7 @@ export class Emitter {
97
101
* Emit an event inside this application
98
102
*
99
103
* @param {CloudEvent } event to emit
100
- * @param {boolean } ensureDelivery fail the promise if one listener fail
104
+ * @param {boolean } ensureDelivery fail the promise if one listener fails
101
105
* @return {void }
102
106
*/
103
107
static async emitEvent ( event : CloudEvent , ensureDelivery = true ) : Promise < void > {
0 commit comments