Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 1x 1x 1x 15x 15x 8x 8x 8x 8x 8x 25x 9x 8x | import { Observable, of, Subject } from 'rxjs';
import { WebSocketService } from './webSocket.service';
export class WebSocketServiceMock implements Partial<WebSocketService> {
private requestStream?: Subject<MessageEvent>;
public constructor(private readonly responseSubject: Subject<MessageEvent>, private readonly desiredType: string) {
}
public get requestSubject(): Subject<MessageEvent> {
Iif (this.requestStream === undefined) {
return this.initRequestStream();
}
return this.requestStream;
}
public createSocket(): Subject<MessageEvent> {
return this.initRequestStream();
}
public getResponseStream(): Observable<MessageEvent> {
Iif (this.responseSubject === undefined) {
return of();
}
return this.responseSubject;
}
private initRequestStream(): Subject<MessageEvent> {
this.requestStream = new Subject<MessageEvent>();
this.requestStream.subscribe((msg) => {
if (this.desiredType === msg.type) {
this.responseSubject.next(msg);
// console.error(`### ${msg?.data} ###`);
}
});
return this.requestStream;
}
}
|