@@ -16,10 +16,8 @@ import type {
1616 MapCallers ,
1717} from './types' ;
1818import type { ErrorRPCRemote } from './errors' ;
19- import { CreateDestroy , ready } from '@matrixai/async-init/dist/CreateDestroy' ;
2019import Logger from '@matrixai/logger' ;
2120import { Timer } from '@matrixai/timer' ;
22- import { createDestroy } from '@matrixai/async-init' ;
2321import * as rpcUtilsMiddleware from './middleware' ;
2422import * as rpcErrors from './errors' ;
2523import * as rpcUtils from './utils' ;
@@ -30,24 +28,8 @@ import { toError } from './utils';
3028
3129const timerCleanupReasonSymbol = Symbol ( 'timerCleanUpReasonSymbol' ) ;
3230
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+
5133class RPCClient < M extends ClientManifest > {
5234 /**
5335 * @param obj
@@ -175,16 +157,9 @@ class RPCClient<M extends ClientManifest> {
175157 } = { } ) : Promise < void > {
176158 this . logger . info ( `Destroying ${ this . constructor . name } ` ) ;
177159
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-
184160 this . logger . info ( `Destroyed ${ this . constructor . name } ` ) ;
185161 }
186162
187- @ready ( new rpcErrors . ErrorRPCCallerFailed ( ) )
188163 public get methods ( ) : MapCallers < M > {
189164 return this . methodsProxy as MapCallers < M > ;
190165 }
@@ -198,7 +173,6 @@ class RPCClient<M extends ClientManifest> {
198173 * the provided I type.
199174 * @param ctx - ContextTimed used for timeouts and cancellation.
200175 */
201- @ready ( new rpcErrors . ErrorMissingCaller ( ) )
202176 public async unaryCaller < I extends JSONValue , O extends JSONValue > (
203177 method : string ,
204178 parameters : I ,
@@ -235,7 +209,6 @@ class RPCClient<M extends ClientManifest> {
235209 * the provided I type.
236210 * @param ctx - ContextTimed used for timeouts and cancellation.
237211 */
238- @ready ( new rpcErrors . ErrorRPCCallerFailed ( ) )
239212 public async serverStreamCaller < I extends JSONValue , O extends JSONValue > (
240213 method : string ,
241214 parameters : I ,
@@ -264,7 +237,6 @@ class RPCClient<M extends ClientManifest> {
264237 * @param method - Method name of the RPC call
265238 * @param ctx - ContextTimed used for timeouts and cancellation.
266239 */
267- @ready ( new rpcErrors . ErrorRPCCallerFailed ( ) )
268240 public async clientStreamCaller < I extends JSONValue , O extends JSONValue > (
269241 method : string ,
270242 ctx : Partial < ContextTimedInput > = { } ,
@@ -299,7 +271,6 @@ class RPCClient<M extends ClientManifest> {
299271 * @param method - Method name of the RPC call
300272 * @param ctx - ContextTimed used for timeouts and cancellation.
301273 */
302- @ready ( new rpcErrors . ErrorRPCCallerFailed ( ) )
303274 public async duplexStreamCaller < I extends JSONValue , O extends JSONValue > (
304275 method : string ,
305276 ctx : Partial < ContextTimedInput > = { } ,
@@ -439,7 +410,6 @@ class RPCClient<M extends ClientManifest> {
439410 * @param ctx - ContextTimed used for timeouts and cancellation.
440411 * @param id - Id is generated only once, and used throughout the stream for the rest of the communication
441412 */
442- @ready ( new rpcErrors . ErrorRPCCallerFailed ( ) )
443413 public async rawStreamCaller (
444414 method : string ,
445415 headerParams : JSONValue ,
0 commit comments