Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function FirebaseObjectFactory (
ref: DatabaseReference,
{ preserveSnapshot }: FirebaseObjectFactoryOpts = {}): FirebaseObjectObservable {
const objectObservable = new FirebaseObjectObservable((obs: Observer) => {
let fn = ref.on('value', (snapshot: DataSnapshot) => {
obs.next(preserveSnapshot ? snapshot : utils.unwrapMapFn(snapshot))
}, err => {
if (err) { obs.error(err); obs.complete(); }
});
return () => ref.off('value', fn);
}, ref);
// TODO: should be in the subscription zone instead
return observeOn.call(objectObservable, new FirebaseZoneScheduler(new NgZone({}), {}));
}
constructor(
@Inject(FirebaseOptionsToken) options:FirebaseOptions,
@Optional() @Inject(FirebaseNameOrConfigToken) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Inject(PLATFORM_ID) platformId: Object,
private zone: NgZone
) {
const scheduler = new FirebaseZoneScheduler(zone, platformId);
this.auth = zone.runOutsideAngular(() => {
const app = _firebaseAppFactory(options, zone, nameOrConfig);
return app.auth();
});
this.authState = scheduler.keepUnstableUntilFirst(
scheduler.runOutsideAngular(
new Observable(subscriber => {
const unsubscribe = this.auth.onAuthStateChanged(subscriber);
return { unsubscribe };
})
)
);
this.user = scheduler.keepUnstableUntilFirst(
scheduler.runOutsideAngular(
constructor(
@Inject(FirebaseOptionsToken) options:FirebaseOptions,
@Optional() @Inject(FirebaseNameOrConfigToken) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Optional() @Inject(RealtimeDatabaseURL) databaseURL:string|null,
@Inject(PLATFORM_ID) platformId: Object,
zone: NgZone
) {
this.scheduler = new FirebaseZoneScheduler(zone, platformId);
this.database = zone.runOutsideAngular(() => {
const app = _firebaseAppFactory(options, zone, nameOrConfig);
return app.database(databaseURL || undefined);
});
}
constructor(
@Inject(FirebaseOptionsToken) options:FirebaseOptions,
@Optional() @Inject(FirebaseNameOrConfigToken) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Inject(PLATFORM_ID) platformId: Object,
zone: NgZone,
@Optional() @Inject(FUNCTIONS_REGION) region:string|null,
@Optional() @Inject(FUNCTIONS_ORIGIN) origin:string|null
) {
this.scheduler = new FirebaseZoneScheduler(zone, platformId);
this.functions = zone.runOutsideAngular(() => {
const app = _firebaseAppFactory(options, zone, nameOrConfig);
return app.functions(region || undefined);
});
if (origin) {
this.functions.useFunctionsEmulator(origin);
}
}
constructor(
@Inject(FirebaseOptionsToken) options:FirebaseOptions,
@Optional() @Inject(FirebaseNameOrConfigToken) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Optional() @Inject(StorageBucket) storageBucket:string|null,
@Inject(PLATFORM_ID) platformId: Object,
zone: NgZone
) {
this.scheduler = new FirebaseZoneScheduler(zone, platformId);
this.storage = zone.runOutsideAngular(() => {
const app = _firebaseAppFactory(options, zone, nameOrConfig);
return app.storage(storageBucket || undefined);
});
}