Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

check change from service variable angular

export class UserService {

userDocumentReady: boolean = false; // initial value is "userdoc is not ready"
userDocObserver: Subject<boolean> = new Subject<boolean>(); // observing that bool

constructor(
  public fireauth: AngularFireAuth,
  public afs: AngularFirestore,
) {

// watch variable
this.userDocObserver.subscribe(value => this.userDocumentReady = value);

this.fireauth.authState
  .subscribe(user => {
    if (user) {

      this.afs.doc(`/tooluser/${user.uid}`).snapshotChanges()
      .subscribe(usr => {
        if (usr.payload.data()) {
          console.log(`got user object from database:`, usr.payload.data());              
          this.currentUser = usr.payload.data();

          this.userDocObserver.next(true); // flip UserDocumentReady flag
Comment

PREVIOUS NEXT
Code Example
Javascript :: Use Prototype To Add A Property To Javascript Class 
Javascript :: nodelist example 
Javascript :: javascript show alert if browser is not google chrome 
Javascript :: string concat in js 
Javascript :: jquery selectors 
Javascript :: what is computed property in vue js 
Javascript :: what are array methods in javascript 
Javascript :: javascript in jsx 
Javascript :: filter 
Javascript :: loop on each character js 
Javascript :: javascript methods 
Javascript :: react native icons 
Javascript :: js function arguments 
Javascript :: asp net core use newtonsoft json 
Javascript :: get id javascript 
Javascript :: in js pass infinite argument in function 
Javascript :: how to create scroll to top button in reactjs example code 
Javascript :: swagger ui express 
Javascript :: type conversion in javascript 
Javascript :: js max number in array mdn 
Javascript :: spotify player react 
Javascript :: how to detect a section is visible in jquery 
Javascript :: sequelize find query to return raw data in json object format 
Javascript :: bs modal service angular pass data 
Javascript :: serializes to the same string 
Javascript :: react validate 
Javascript :: javascript double exclamation mark 
Javascript :: signalr 
Javascript :: find element vs find elements 
Javascript :: is javascript loosely typed 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =