Christopher You
Christopher You

Reputation: 63

Refreshing data from FireStore GET subscription- Angular - Firebase/FireStore

I am subscribing to Firestore's document "this.afs.collection('messaging').doc(email);" which is located in NgOnInit(). Once I Create another document in Firestore, I want to refresh the data. I am a little confused on the best way to do this. I have tried "window.location.reload()" and my POST operation does not follow through. I have also tried using changeDetector which has not helped as well.

COMPONENT

ngOnInit(){
const doc = this.afs.collection('messaging').doc(email);
doc.subscribe( usersData => { this.users = usersData });

`

`

TEMPLATE

<ng-container *ngFor="let user of users;index as i">
{{user.payload.doc.data().displayName}}
</ng-container>

`

Upvotes: 0

Views: 341

Answers (1)

Eliya Cohen
Eliya Cohen

Reputation: 11478

According to the pattern I assume you use @angular/fire. Plus, you're dealing here with websockets behind the scene meaning that everything that happens here occurs in real-time. Meaning, you don't have to refresh anything.

Upvotes: 1

Related Questions