@@ -34,9 +34,6 @@ import { EntityState, EntitySubjectStore } from './entity-state.js';
3434import { assertType , deserializeType , ReflectionKind , Type , TypeObjectLiteral , typeOf } from '@deepkit/type' ;
3535import { ProgressTracker , ProgressTrackerState } from '@deepkit/core-rxjs' ;
3636
37- interface ResponseActionObservableError extends rpcActionObservableSubscribeId , WrappedV {
38- }
39-
4037type ControllerStateActionTypes = {
4138 callSchema : TypeObjectLiteral , //with args, method, and controller as property
4239 resultSchema : TypeObjectLiteral , //with v as property
@@ -56,7 +53,7 @@ export class RpcControllerState {
5653 public peerId ?: string ;
5754
5855 constructor (
59- public controller : string
56+ public controller : string ,
6057 ) {
6158
6259 }
@@ -87,7 +84,11 @@ export class RpcActionClient {
8784 constructor ( protected client : WritableClient ) {
8885 }
8986
90- public action < T > ( controller : RpcControllerState , method : string , args : any [ ] , options : { timeout ?: number , dontWaitForConnection ?: true , typeReuseDisabled ?: boolean } = { } ) {
87+ public action < T > ( controller : RpcControllerState , method : string , args : any [ ] , options : {
88+ timeout ?: number ,
89+ dontWaitForConnection ?: true ,
90+ typeReuseDisabled ?: boolean
91+ } = { } ) {
9192 const progress = ClientProgress . getNext ( ) ;
9293
9394 return asyncOperation < any > ( async ( resolve , reject ) => {
@@ -112,12 +113,12 @@ export class RpcActionClient {
112113 const subject = this . client . sendMessage ( RpcTypes . Action , {
113114 controller : controller . controller ,
114115 method : method ,
115- args
116+ args,
116117 } , types . callSchema , {
117118 peerId : controller . peerId ,
118119 dontWaitForConnection : options . dontWaitForConnection ,
119120 timeout : options . timeout ,
120- } ) . onReply ( ( reply ) => {
121+ } ) . onRejected ( reject ) . onReply ( ( reply ) => {
121122 try {
122123 // console.log('client: answer', RpcTypes[reply.type], reply.composite);
123124
@@ -207,7 +208,7 @@ export class RpcActionClient {
207208 unsubscribe : ( ) => {
208209 delete subscribers [ id ] ;
209210 subject . send < rpcActionObservableSubscribeId > ( RpcTypes . ActionObservableUnsubscribe , { id } ) ;
210- }
211+ } ,
211212 } ;
212213 } ) ;
213214 ( observable as any ) . disconnect = ( ) => {
@@ -257,7 +258,7 @@ export class RpcActionClient {
257258 //whenever the client changes something, it's synced back to the server.
258259 //this is important to handle the stop signal.
259260 const oldChanged = observableSubject . changed ;
260- observableSubject . changed = function ( this : ProgressTracker ) {
261+ observableSubject . changed = function ( this : ProgressTracker ) {
261262 subject . send ( RpcTypes . ActionObservableProgressNext , this . value , typeOf < ProgressTrackerState [ ] > ( ) ) ;
262263 return oldChanged . apply ( this ) ;
263264 } ;
@@ -434,12 +435,12 @@ export class RpcActionClient {
434435 const a = this . client . sendMessage < rpcActionType > ( RpcTypes . ActionType , {
435436 controller : controller . controller ,
436437 method : method ,
437- disableTypeReuse : typeReuseDisabled
438+ disableTypeReuse : typeReuseDisabled ,
438439 } , undefined , {
439440 peerId : controller . peerId ,
440441 dontWaitForConnection : options . dontWaitForConnection ,
441442 timeout : options . timeout ,
442- } ) ;
443+ } ) . onRejected ( reject ) ;
443444
444445 const parsed = await a . firstThenClose < rpcResponseActionType > ( RpcTypes . ResponseActionType , typeOf < rpcResponseActionType > ( ) ) ;
445446
@@ -465,8 +466,8 @@ export class RpcActionClient {
465466 name : 'v' ,
466467 parent : Object as any ,
467468 optional : true ,
468- type : { kind : ReflectionKind . array , type : unwrappedReturnType }
469- } ]
469+ type : { kind : ReflectionKind . array , type : unwrappedReturnType } ,
470+ } ] ,
470471 } ;
471472 }
472473
@@ -480,21 +481,21 @@ export class RpcActionClient {
480481 { kind : ReflectionKind . propertySignature , name : 'controller' , type : { kind : ReflectionKind . string } } ,
481482 { kind : ReflectionKind . propertySignature , name : 'method' , type : { kind : ReflectionKind . string } } ,
482483 { kind : ReflectionKind . propertySignature , name : 'args' , type : parameters } ,
483- ]
484+ ] ,
484485 } as TypeObjectLiteral ,
485486 resultSchema : {
486487 kind : ReflectionKind . objectLiteral ,
487488 types : [
488489 { kind : ReflectionKind . propertySignature , name : 'v' , type : unwrappedReturnType } ,
489- ]
490+ ] ,
490491 } as TypeObjectLiteral ,
491492 observableNextSchema : {
492493 kind : ReflectionKind . objectLiteral ,
493494 types : [
494495 { kind : ReflectionKind . propertySignature , name : 'id' , type : { kind : ReflectionKind . number } } ,
495496 { kind : ReflectionKind . propertySignature , name : 'v' , type : unwrappedReturnType } ,
496- ]
497- } as TypeObjectLiteral
497+ ] ,
498+ } as TypeObjectLiteral ,
498499 } ;
499500
500501 resolve ( state . types ) ;
0 commit comments