import { Injectable } from '@nestjs/common' ; import { Observable , Subject } from 'rxjs' ; import { api } from '@grpc-proto/chat/chat.types' ; @ Injectable ( ) export class ChatEventService { private readonly updates$ = new Subject < api . chat . Message [ ] > ( ) ; public emit ( message ) { this . updates$ . next ( [ message ] ) ; } public broadcast ( ) { return this . updates$ . asObservable ( ) ; } }