I'm learning how Observables work through Angular and Google Firestore.
this.allinvoicesCollection = this.afs.collection('clients').doc(this.clientId).collection('inbox').valueChanges();
this.allinvoicesCollection.subscribe(val => {
this.fileUrl = val[this.currentIndex].downloadURL;
})
I'm fetching the fileUrl with the above code.
I want to update the fileUrl whenever the variable "this.currentIndex" changes however the above code obviously doesn't achieve that.
I understand that this only triggers when a doc is changed in the collection. How would I make it trigger when detecting change in "this.currentIndex"? I should mention that "this.currentIndex" is not an Observable just a simple number variable changed by the user.