import { Subject, from } from 'rxjs'; import * as fs from 'fs' export * from './services/server-client.service'; const messagesJSON: any = fs.readFileSync('payload.json') let parsedMessages = JSON.parse(messagesJSON) function generateFakeStreamResponse(request: any): Subject { let res: Subject = new Subject() from(parsedMessages.slice(0, 10)).subscribe({ next: element => { let message = { id: request.id, message: element } res.next(message) }, error: error => console.error(error), complete: () => console.log(`Stream response for ${request.id} has been prepared.`) }) return res } generateFakeStreamResponse({ id: '123', message: 'DOnt lie to me boy' }).subscribe((e => console.log(e)))