ngOnInit() { collection(`cats`) .where('chat_room.id', '==', '2a4b86fc') .where('created_at_timestamp', '>', 101) .on() .subscribe( data => console.log('message received:', data), error => console.log(error) ); } sendMessages() { // // Validate, only a few messages if (this.timestamp > 120) return; // // Inc this.timestamp++; setInterval(async () => { console.log('sending another message:', this.timestamp); const id = Guid.make(2); // // Create message await collection(`cats`) .doc(id) .set({ id: id, chat_room: { id: '2a4b86fc' }, to: { uid: 'GlGkOGSYbCNqBK6uaXf7USALw2c2', display_name: 'Matheus Receiver' }, from: { uid: 'GlGkOGSYbCNqBK6uaXf7USALw2c2', display_name: 'Matheus Sender' }, isFile: false, file: {}, message: `message: ${this.timestamp}`, created_at: new Date().toISOString(), created_at_timestamp: this.timestamp }) .toPromise().then(()=>this.timestamp+=1); }, 1000); }