import { from, map, Observable, of, Subject } from "rxjs"; import * as fs from "fs" import { BaseMessage } from "../dependencies/fisloggingservice/services/logging-service"; export class StreamingService { private messagesJSON: any = fs.readFileSync("testRequest.json") private messages = JSON.parse(this.messagesJSON) // public stream(): Observable { // return new Observable(subject => { // let messages = this.messages // let count = 0 // const intervalId = setInterval(() => { // subject.next(messages[count]); // count++; // if (count >= 4) { // clearInterval(intervalId); // subject.complete(); // } // }, 1000) // }) // } public stream(): Subject { let result: Subject = new Subject() let messages = this.messages let count = 0 const intervalId = setInterval(() => { result.next(messages[count]); count++; if (count >= 4) { clearInterval(intervalId); result.complete(); } }, 1000) return result } }