mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-24 04:24:52 +08:00
[auth][ios] finalised auth changed listener logic
This commit is contained in:
@@ -37,9 +37,9 @@ export default class FirebaseApp {
|
||||
this._nativeInitialized = true;
|
||||
} else {
|
||||
FirebaseCoreModule.initializeApp(this._name, this._options, (error, result) => {
|
||||
// todo check error/result
|
||||
this._initialized = true;
|
||||
this._nativeInitialized = false;
|
||||
INTERNALS.SharedEventEmitter.emit(`AppReady:${this._name}`, { error, result });
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,17 @@ export default class FirebaseApp {
|
||||
}
|
||||
|
||||
|
||||
onReady(): Promise {
|
||||
if (this._initialized) return Promise.resolve(this);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
INTERNALS.SharedEventEmitter.once(`AppReady:${this._name}`, ({ error }) => {
|
||||
if (error) return reject(new Error(error)); // error is a string as it's from native
|
||||
return resolve(this); // return app
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* MODULES
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user