started work on multiple app initialization

This commit is contained in:
Salakar
2017-06-29 17:24:34 +01:00
parent 7db8b07f34
commit 80ae8425ce
14 changed files with 651 additions and 326 deletions

View File

@@ -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:
}
/**