Skip to content

Commit

Permalink
fix: TReqIn and TReqOut usage
Browse files Browse the repository at this point in the history
  • Loading branch information
nichita-pasecinic committed Feb 8, 2024
1 parent 84eb054 commit 28ee7bd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/thirty-games-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nichitaa/rxjs-ws": patch
---

fix types for `TReqIn` and `TReqOut`
4 changes: 2 additions & 2 deletions src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface StreamResponse<TRes, TReqOut, TErr> {
export interface StreamHandlerParams<TEvent, TRes = TEvent, TReqIn = unknown, TReqOut = TReqIn> {
default: TRes;
transformRequests: TransformOperator<
SendRequestParams<TEvent, TRes, TReqIn>,
SendRequestParams<TEvent, TRes, TReqIn, TReqOut>,
SendRequestParams<TEvent, TRes, TReqOut>
>;
resetResponseOnNextRequest: boolean;
Expand All @@ -64,7 +64,7 @@ export interface StreamHandler<
> {
$: BehaviorSubject<StreamResponse<TRes, TReqOut, TErr>>;

send(params: SendRequestParams<TEvent, TRes, TReqIn>): void;
send(params: SendRequestParams<TEvent, TRes, TReqIn, TReqOut>): void;
}

export type TransformResponse<TEvent, TRes = TEvent, TReqOut = unknown> = (
Expand Down
10 changes: 5 additions & 5 deletions src/core/web-socket-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class WebSocketConnector {
params: Partial<StreamHandlerParams<TEvent, TRes, TReqIn, TReqOut>> = {},
): StreamHandler<TEvent, TRes, TReqIn, TReqOut, TErr> => {
const defaultTransformRequest = identity as TransformOperator<
SendRequestParams<TEvent, TRes, TReqIn>,
SendRequestParams<TEvent, TRes, TReqIn, TReqOut>,
SendRequestParams<TEvent, TRes, TReqOut>
>;

Expand All @@ -180,9 +180,9 @@ export class WebSocketConnector {
awaitReadyStatusBeforeNextRequest = true,
} = params;

const requests$ = new BehaviorSubject<undefined | SendRequestParams<TEvent, TRes, TReqIn>>(
undefined,
);
const requests$ = new BehaviorSubject<
undefined | SendRequestParams<TEvent, TRes, TReqIn, TReqOut>
>(undefined);
const uninitializedValue: StreamResponse<TRes, TReqOut, TErr> = {
status: STREAM_STATUS.uninitialized,
response: defaultResponse,
Expand Down Expand Up @@ -282,7 +282,7 @@ export class WebSocketConnector {
},
});

const send = (params: SendRequestParams<TEvent, TRes, TReqIn>) => {
const send = (params: SendRequestParams<TEvent, TRes, TReqIn, TReqOut>) => {
// create a shallow copy of the send request params to referentially check it in nextRequest$
requests$.next({ ...params });
};
Expand Down

0 comments on commit 28ee7bd

Please sign in to comment.