peter 4 роки тому
джерело
коміт
887e51392d
2 змінених файлів з 17 додано та 9 видалено
  1. 11
    9
      docs/modules/_utils_.md
  2. 6
    0
      src/Utils.ts

+ 11
- 9
docs/modules/_utils_.md Переглянути файл

18
 
18
 
19
 ▸ **extractArgs**(`f`: Function): *T.Arg[]*
19
 ▸ **extractArgs**(`f`: Function): *T.Arg[]*
20
 
20
 
21
-Defined in Utils.ts:96
21
+Defined in Utils.ts:102
22
 
22
 
23
 **Parameters:**
23
 **Parameters:**
24
 
24
 
34
 
34
 
35
 ▸ **hookGenerator**(`rpc`: T.HookRPC‹any›): *function*
35
 ▸ **hookGenerator**(`rpc`: T.HookRPC‹any›): *function*
36
 
36
 
37
-Defined in Utils.ts:75
37
+Defined in Utils.ts:81
38
 
38
 
39
 **Parameters:**
39
 **Parameters:**
40
 
40
 
58
 
58
 
59
 ▸ **makeSubResponse**(`uuid?`: undefined | string): *[SubscriptionResponse](_types_.md#subscriptionresponse)*
59
 ▸ **makeSubResponse**(`uuid?`: undefined | string): *[SubscriptionResponse](_types_.md#subscriptionresponse)*
60
 
60
 
61
-Defined in Utils.ts:101
61
+Defined in Utils.ts:107
62
 
62
 
63
 **Parameters:**
63
 **Parameters:**
64
 
64
 
74
 
74
 
75
 ▸ **rpcHooker**<**SubResT**>(`socket`: [Socket](../interfaces/_interfaces_.socket.md), `exporter`: [Exporter](../interfaces/_interfaces_.exporter.md)‹SubResT›, `makeUnique`: boolean): *T.ExtendedRpcInfo[]*
75
 ▸ **rpcHooker**<**SubResT**>(`socket`: [Socket](../interfaces/_interfaces_.socket.md), `exporter`: [Exporter](../interfaces/_interfaces_.exporter.md)‹SubResT›, `makeUnique`: boolean): *T.ExtendedRpcInfo[]*
76
 
76
 
77
-Defined in Utils.ts:53
77
+Defined in Utils.ts:59
78
+
79
+Utility function to apply the RPCs of an [Exporter](../interfaces/_interfaces_.exporter.md).
78
 
80
 
79
 **Type parameters:**
81
 **Type parameters:**
80
 
82
 
82
 
84
 
83
 **Parameters:**
85
 **Parameters:**
84
 
86
 
85
-Name | Type | Default |
86
------- | ------ | ------ |
87
-`socket` | [Socket](../interfaces/_interfaces_.socket.md) | - |
88
-`exporter` | [Exporter](../interfaces/_interfaces_.exporter.md)‹SubResT› | - |
89
-`makeUnique` | boolean | true |
87
+Name | Type | Default | Description |
88
+------ | ------ | ------ | ------ |
89
+`socket` | [Socket](../interfaces/_interfaces_.socket.md) | - | The websocket (implementation: bsock) to hook on |
90
+`exporter` | [Exporter](../interfaces/_interfaces_.exporter.md)‹SubResT› | - | The exporter |
91
+`makeUnique` | boolean | true | @default true Attach a suffix to RPC names  |
90
 
92
 
91
 **Returns:** *T.ExtendedRpcInfo[]*
93
 **Returns:** *T.ExtendedRpcInfo[]*
92
 
94
 

+ 6
- 0
src/Utils.ts Переглянути файл

50
     throw new Error("Bad socketIORPC type "+ typeof rpc)
50
     throw new Error("Bad socketIORPC type "+ typeof rpc)
51
 }
51
 }
52
 
52
 
53
+/**
54
+ * Utility function to apply the RPCs of an {@link Exporter}.
55
+ * @param socket The websocket (implementation: bsock) to hook on
56
+ * @param exporter The exporter
57
+ * @param makeUnique @default true Attach a suffix to RPC names
58
+ */
53
 export function rpcHooker<SubResT = {}>(socket: I.Socket, exporter:I.Exporter<SubResT>, makeUnique = true):T.ExtendedRpcInfo[]{
59
 export function rpcHooker<SubResT = {}>(socket: I.Socket, exporter:I.Exporter<SubResT>, makeUnique = true):T.ExtendedRpcInfo[]{
54
     const owner = exporter.name
60
     const owner = exporter.name
55
     const RPCs = [...exporter.exportRPCs()]
61
     const RPCs = [...exporter.exportRPCs()]

Завантаження…
Відмінити
Зберегти