import { from, map, Observable, of } from "rxjs"; import * as fs from "fs" export class StreamingService { private messagesJSON: any = fs.readFileSync("dependencies/fisloggingservice/messages.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 >= 7) { clearInterval(intervalId); observer.complete(); } }, 1000) }) } }