mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-24 04:24:52 +08:00
started work on multiple app initialization
This commit is contained in:
@@ -2,8 +2,7 @@
|
||||
import { NativeModules, NativeEventEmitter } from 'react-native';
|
||||
|
||||
import User from './user';
|
||||
import { Base } from './../base';
|
||||
import { nativeSDKMissing } from './../../utils';
|
||||
import ModuleBase from './../../utils/ModuleBase';
|
||||
|
||||
// providers
|
||||
import EmailAuthProvider from './providers/Email';
|
||||
@@ -13,26 +12,19 @@ import TwitterAuthProvider from './providers/Twitter';
|
||||
import GithubAuthProvider from './providers/Github';
|
||||
|
||||
const FirebaseAuth = NativeModules.RNFirebaseAuth;
|
||||
const FirebaseAuthEvt = FirebaseAuth && new NativeEventEmitter(FirebaseAuth);
|
||||
|
||||
export default class Auth extends Base {
|
||||
export default class Auth extends ModuleBase {
|
||||
_user: User | null;
|
||||
_authResult: AuthResultType | null;
|
||||
authenticated: boolean;
|
||||
|
||||
constructor(firebase: Object, options: Object = {}) {
|
||||
super(firebase, options);
|
||||
if (!FirebaseAuth) {
|
||||
return nativeSDKMissing('auth');
|
||||
}
|
||||
|
||||
constructor(firebaseApp: Object, options: Object = {}) {
|
||||
super(firebaseApp, options, 'auth');
|
||||
this._user = null;
|
||||
this._authResult = null;
|
||||
this.authenticated = false;
|
||||
|
||||
// start listening immediately for auth changes
|
||||
FirebaseAuthEvt.addListener('onAuthStateChanged', this._onAuthStateChanged.bind(this));
|
||||
FirebaseAuth.addAuthStateListener();
|
||||
this.addListener('onAuthStateChanged', this._onAuthStateChanged.bind(this));
|
||||
this._native.addAuthStateListener(); // this is the native function on ios/android:
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user