packages/auth/demo/public/web-worker.js
function() {
  return new Promise(function(resolve, reject) {
    firebase.auth().onAuthStateChanged(function(user) {
      if (user) {
        user.getIdToken().then(function(idToken) {
          resolve(idToken);
        }, function(error) {
          resolve(null);
        });
      } else {
        resolve(null);
      }
    });
  }).catch(function(error) {
    console.log(error);
  });
}
function() {
  return new Promise(function(resolve, reject) {
    firebase.auth().onAuthStateChanged(function(user) {
      if (user) {
        user.getIdToken().then(function(idToken) {
          resolve(idToken);
        }, function(error) {
          resolve(null);
        });
      } else {
        resolve(null);
      }
    });
  }).catch(function(error) {
    console.log(error);
  });
}
function ( ) { return new Promise ( function ( resolve , reject ) { firebase . auth ( ) . onAuthStateChanged ( function ( user ) { if ( user ) { user . getIdToken ( ) . then ( function ( idToken ) { resolve ( idToken ) ; } , function ( error ) { resolve ( null ) ; } ) ; } else { resolve ( null ) ; } } ) ; } ) . catch ( function ( error ) { console . log ( error ) ; } ) ; }
Returns a promise that resolves with an ID token if available.
@return {!Promise<?string>} The promise that resolves with an ID token if
available. Otherwise, the promise resolves with null.
Returns a promise that resolves with an ID token if available .