import { BehaviorSubject, Observable, Subject, interval } from "rxjs"; import { BufferService } from "../services/buffer.service"; import { ConnectionState } from "../interfaces/general.interface"; // let obs1 = new Subject let obs1 = new Subject; interval(1000).subscribe( { next:(msg)=>{ obs1.next(msg) } } ); let initialReport = { status: 'DIRECT_PUBLISH' } let reportSubject: BehaviorSubject = new BehaviorSubject(initialReport) let retransmission = new BufferService(obs1, reportSubject, 'mongo') let result: Observable = retransmission.getMessages() result.subscribe(e => console.log(e)) let publishBUFFER: ConnectionState = { status: `BUFFER` } let publishDIRECT_PUBLISH: ConnectionState = { status: `DIRECT_PUBLISH` } setTimeout(()=>{ reportSubject.next(publishBUFFER); },5000) setTimeout(()=>{ reportSubject.next(publishDIRECT_PUBLISH); },10000) // let initialReport = { status: 'BUFFER' } // let reportSubject: BehaviorSubject = new BehaviorSubject(initialReport) // let retransmission = new BufferService(obs1, reportSubject, 'mongo', 5) // retransmission.getMessages().subscribe(e => console.log(e))