12345678910111213141516171819202122 |
- 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<any> {
- 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)
- })
- }
- }
|