Skip to content

Instantly share code, notes, and snippets.

@stewones
Last active December 4, 2019 15:13
Show Gist options
  • Save stewones/13450464b52921484ce328ab14468739 to your computer and use it in GitHub Desktop.
Save stewones/13450464b52921484ce328ab14468739 to your computer and use it in GitHub Desktop.
.on test
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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment