How to retrieve real time changes in firebase using angular and firestore [closed]









up vote
0
down vote

favorite












i am quite new to observables and firebase. I want to retrieve changes from my firestore to my angular app when a change happens. For example i want to send an alert from my component when field isOnline from my user document changes from false to true(this will be done by the admin). How can i go about it?



From the example The Unreal gave ;



constructor(db: AngularFirestore) {
this.user = db.collection('users/1').valueChanges().subscribe((userData) =>
// put your logic here
console.log(userData);;



If userdata has a field of let's say isOnline which is false from the onset. If an admin changes it to true i want to take that change from that service and alert my component or in this instance, my ionic page of that change and display an alert in my html file.



if in my ts file i have a public variable of let's say isOnline which i initialized to false. If it is true then display an alrt controller in my html file. How do i go about it?










share|improve this question















closed as too broad by R. Richards, SiddAjmera, Pankaj Parkar, pirho, TheUnreal Nov 10 at 16:22


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • Have you tried anything so far?
    – SiddAjmera
    Nov 10 at 15:28














up vote
0
down vote

favorite












i am quite new to observables and firebase. I want to retrieve changes from my firestore to my angular app when a change happens. For example i want to send an alert from my component when field isOnline from my user document changes from false to true(this will be done by the admin). How can i go about it?



From the example The Unreal gave ;



constructor(db: AngularFirestore) {
this.user = db.collection('users/1').valueChanges().subscribe((userData) =>
// put your logic here
console.log(userData);;



If userdata has a field of let's say isOnline which is false from the onset. If an admin changes it to true i want to take that change from that service and alert my component or in this instance, my ionic page of that change and display an alert in my html file.



if in my ts file i have a public variable of let's say isOnline which i initialized to false. If it is true then display an alrt controller in my html file. How do i go about it?










share|improve this question















closed as too broad by R. Richards, SiddAjmera, Pankaj Parkar, pirho, TheUnreal Nov 10 at 16:22


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • Have you tried anything so far?
    – SiddAjmera
    Nov 10 at 15:28












up vote
0
down vote

favorite









up vote
0
down vote

favorite











i am quite new to observables and firebase. I want to retrieve changes from my firestore to my angular app when a change happens. For example i want to send an alert from my component when field isOnline from my user document changes from false to true(this will be done by the admin). How can i go about it?



From the example The Unreal gave ;



constructor(db: AngularFirestore) {
this.user = db.collection('users/1').valueChanges().subscribe((userData) =>
// put your logic here
console.log(userData);;



If userdata has a field of let's say isOnline which is false from the onset. If an admin changes it to true i want to take that change from that service and alert my component or in this instance, my ionic page of that change and display an alert in my html file.



if in my ts file i have a public variable of let's say isOnline which i initialized to false. If it is true then display an alrt controller in my html file. How do i go about it?










share|improve this question















i am quite new to observables and firebase. I want to retrieve changes from my firestore to my angular app when a change happens. For example i want to send an alert from my component when field isOnline from my user document changes from false to true(this will be done by the admin). How can i go about it?



From the example The Unreal gave ;



constructor(db: AngularFirestore) {
this.user = db.collection('users/1').valueChanges().subscribe((userData) =>
// put your logic here
console.log(userData);;



If userdata has a field of let's say isOnline which is false from the onset. If an admin changes it to true i want to take that change from that service and alert my component or in this instance, my ionic page of that change and display an alert in my html file.



if in my ts file i have a public variable of let's say isOnline which i initialized to false. If it is true then display an alrt controller in my html file. How do i go about it?







angular firebase ionic-framework angularfire2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 16:48

























asked Nov 10 at 15:27









Patrick Obafemi

112113




112113




closed as too broad by R. Richards, SiddAjmera, Pankaj Parkar, pirho, TheUnreal Nov 10 at 16:22


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as too broad by R. Richards, SiddAjmera, Pankaj Parkar, pirho, TheUnreal Nov 10 at 16:22


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.













  • Have you tried anything so far?
    – SiddAjmera
    Nov 10 at 15:28
















  • Have you tried anything so far?
    – SiddAjmera
    Nov 10 at 15:28















Have you tried anything so far?
– SiddAjmera
Nov 10 at 15:28




Have you tried anything so far?
– SiddAjmera
Nov 10 at 15:28












1 Answer
1






active

oldest

votes

















up vote
1
down vote













If you are using angularfire2, you can simply use the valueChanges() method of an AngularFireList<T> instance.



For example:



constructor(db: AngularFirestore) {
this.user = db.collection('users/1').valueChanges().subscribe((userData) =>
// put your logic here
console.log(userData);;



userDatacontains latest information in your users/1 document.



For more examples & basic usage details, please check the repository page.






share|improve this answer




















  • Okay this is actually helpful. I need further help from here. I will update my code to make my question more precise using the example you gave.
    – Patrick Obafemi
    Nov 10 at 16:43

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













If you are using angularfire2, you can simply use the valueChanges() method of an AngularFireList<T> instance.



For example:



constructor(db: AngularFirestore) {
this.user = db.collection('users/1').valueChanges().subscribe((userData) =>
// put your logic here
console.log(userData);;



userDatacontains latest information in your users/1 document.



For more examples & basic usage details, please check the repository page.






share|improve this answer




















  • Okay this is actually helpful. I need further help from here. I will update my code to make my question more precise using the example you gave.
    – Patrick Obafemi
    Nov 10 at 16:43














up vote
1
down vote













If you are using angularfire2, you can simply use the valueChanges() method of an AngularFireList<T> instance.



For example:



constructor(db: AngularFirestore) {
this.user = db.collection('users/1').valueChanges().subscribe((userData) =>
// put your logic here
console.log(userData);;



userDatacontains latest information in your users/1 document.



For more examples & basic usage details, please check the repository page.






share|improve this answer




















  • Okay this is actually helpful. I need further help from here. I will update my code to make my question more precise using the example you gave.
    – Patrick Obafemi
    Nov 10 at 16:43












up vote
1
down vote










up vote
1
down vote









If you are using angularfire2, you can simply use the valueChanges() method of an AngularFireList<T> instance.



For example:



constructor(db: AngularFirestore) {
this.user = db.collection('users/1').valueChanges().subscribe((userData) =>
// put your logic here
console.log(userData);;



userDatacontains latest information in your users/1 document.



For more examples & basic usage details, please check the repository page.






share|improve this answer












If you are using angularfire2, you can simply use the valueChanges() method of an AngularFireList<T> instance.



For example:



constructor(db: AngularFirestore) {
this.user = db.collection('users/1').valueChanges().subscribe((userData) =>
// put your logic here
console.log(userData);;



userDatacontains latest information in your users/1 document.



For more examples & basic usage details, please check the repository page.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 10 at 16:22









TheUnreal

6,0492682153




6,0492682153











  • Okay this is actually helpful. I need further help from here. I will update my code to make my question more precise using the example you gave.
    – Patrick Obafemi
    Nov 10 at 16:43
















  • Okay this is actually helpful. I need further help from here. I will update my code to make my question more precise using the example you gave.
    – Patrick Obafemi
    Nov 10 at 16:43















Okay this is actually helpful. I need further help from here. I will update my code to make my question more precise using the example you gave.
– Patrick Obafemi
Nov 10 at 16:43




Okay this is actually helpful. I need further help from here. I will update my code to make my question more precise using the example you gave.
– Patrick Obafemi
Nov 10 at 16:43



這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3