import { from, map, Observable, of } 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(observer => { let messages = this.messages let count = 0 const intervalId = setInterval(() => { observer.next(messages[count]); count++; if (count >= 4) { clearInterval(intervalId); observer.complete(); } }, 1000) }) } }