@@ -16,10 +16,8 @@ import type {
16
16
MapCallers ,
17
17
} from './types' ;
18
18
import type { ErrorRPCRemote } from './errors' ;
19
- import { CreateDestroy , ready } from '@matrixai/async-init/dist/CreateDestroy' ;
20
19
import Logger from '@matrixai/logger' ;
21
20
import { Timer } from '@matrixai/timer' ;
22
- import { createDestroy } from '@matrixai/async-init' ;
23
21
import * as rpcUtilsMiddleware from './middleware' ;
24
22
import * as rpcErrors from './errors' ;
25
23
import * as rpcUtils from './utils' ;
@@ -30,24 +28,8 @@ import { toError } from './utils';
30
28
31
29
const timerCleanupReasonSymbol = Symbol ( 'timerCleanUpReasonSymbol' ) ;
32
30
33
- /**
34
- * Events:
35
- * - {@link events.Event}
36
- */
37
- interface RPCClient < M extends ClientManifest >
38
- extends createDestroy . CreateDestroy { }
39
- /**
40
- * You must provide an error handler `addEventListener('error')`.
41
- * Otherwise, errors will just be ignored.
42
- *
43
- * Events:
44
- * - {@link events.EventRPCClientDestroy}
45
- * - {@link events.EventRPCClientDestroyed}
46
- */
47
- @createDestroy . CreateDestroy ( {
48
- eventDestroy : events . EventRPCClientDestroy ,
49
- eventDestroyed : events . EventRPCClientDestroyed ,
50
- } )
31
+ interface RPCClient < M extends ClientManifest > { }
32
+
51
33
class RPCClient < M extends ClientManifest > {
52
34
/**
53
35
* @param obj
@@ -175,16 +157,9 @@ class RPCClient<M extends ClientManifest> {
175
157
} = { } ) : Promise < void > {
176
158
this . logger . info ( `Destroying ${ this . constructor . name } ` ) ;
177
159
178
- // You can dispatch an event before the actual destruction starts
179
- this . dispatchEvent ( new events . EventRPCClientDestroy ( ) ) ;
180
-
181
- // Dispatch an event after the client has been destroyed
182
- this . dispatchEvent ( new events . EventRPCClientDestroyed ( ) ) ;
183
-
184
160
this . logger . info ( `Destroyed ${ this . constructor . name } ` ) ;
185
161
}
186
162
187
- @ready ( new rpcErrors . ErrorRPCCallerFailed ( ) )
188
163
public get methods ( ) : MapCallers < M > {
189
164
return this . methodsProxy as MapCallers < M > ;
190
165
}
@@ -198,7 +173,6 @@ class RPCClient<M extends ClientManifest> {
198
173
* the provided I type.
199
174
* @param ctx - ContextTimed used for timeouts and cancellation.
200
175
*/
201
- @ready ( new rpcErrors . ErrorMissingCaller ( ) )
202
176
public async unaryCaller < I extends JSONValue , O extends JSONValue > (
203
177
method : string ,
204
178
parameters : I ,
@@ -235,7 +209,6 @@ class RPCClient<M extends ClientManifest> {
235
209
* the provided I type.
236
210
* @param ctx - ContextTimed used for timeouts and cancellation.
237
211
*/
238
- @ready ( new rpcErrors . ErrorRPCCallerFailed ( ) )
239
212
public async serverStreamCaller < I extends JSONValue , O extends JSONValue > (
240
213
method : string ,
241
214
parameters : I ,
@@ -264,7 +237,6 @@ class RPCClient<M extends ClientManifest> {
264
237
* @param method - Method name of the RPC call
265
238
* @param ctx - ContextTimed used for timeouts and cancellation.
266
239
*/
267
- @ready ( new rpcErrors . ErrorRPCCallerFailed ( ) )
268
240
public async clientStreamCaller < I extends JSONValue , O extends JSONValue > (
269
241
method : string ,
270
242
ctx : Partial < ContextTimedInput > = { } ,
@@ -299,7 +271,6 @@ class RPCClient<M extends ClientManifest> {
299
271
* @param method - Method name of the RPC call
300
272
* @param ctx - ContextTimed used for timeouts and cancellation.
301
273
*/
302
- @ready ( new rpcErrors . ErrorRPCCallerFailed ( ) )
303
274
public async duplexStreamCaller < I extends JSONValue , O extends JSONValue > (
304
275
method : string ,
305
276
ctx : Partial < ContextTimedInput > = { } ,
@@ -439,7 +410,6 @@ class RPCClient<M extends ClientManifest> {
439
410
* @param ctx - ContextTimed used for timeouts and cancellation.
440
411
* @param id - Id is generated only once, and used throughout the stream for the rest of the communication
441
412
*/
442
- @ready ( new rpcErrors . ErrorRPCCallerFailed ( ) )
443
413
public async rawStreamCaller (
444
414
method : string ,
445
415
headerParams : JSONValue ,
0 commit comments