UNPKG

@angular/fire

Version:

The official library for Firebase and Angular

110 lines (104 loc) 4.2 kB
import { InjectionToken, Injectable, Inject, Optional, NgZone, ɵɵdefineInjectable, ɵɵinject, NgModule } from '@angular/core'; import { of, from } from 'rxjs'; import { observeOn, switchMap, map, tap, shareReplay } from 'rxjs/operators'; import { ɵAngularFireSchedulers, ɵfirebaseAppFactory, ɵlazySDKProxy, FIREBASE_OPTIONS, FIREBASE_APP_NAME } from '@angular/fire'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const ORIGIN = new InjectionToken('angularfire2.functions.origin'); /** @type {?} */ const REGION = new InjectionToken('angularfire2.functions.region'); // WARNING: interface has both a type and a value, skipping emit class AngularFireFunctions { /** * @param {?} options * @param {?} nameOrConfig * @param {?} zone * @param {?} region * @param {?} origin */ constructor(options, nameOrConfig, zone, region, origin) { /** @type {?} */ const schedulers = new ɵAngularFireSchedulers(zone); /** @type {?} */ const functions = of(undefined).pipe(observeOn(schedulers.outsideAngular), switchMap((/** * @return {?} */ () => import('firebase/functions'))), map((/** * @return {?} */ () => ɵfirebaseAppFactory(options, zone, nameOrConfig))), map((/** * @param {?} app * @return {?} */ app => app.functions(region || undefined))), tap((/** * @param {?} functions * @return {?} */ functions => { if (origin) { functions.useFunctionsEmulator(origin); } })), shareReplay({ bufferSize: 1, refCount: false })); this.httpsCallable = (/** * @template T, R * @param {?} name * @return {?} */ (name) => (/** * @param {?} data * @return {?} */ (data) => from(functions).pipe(observeOn(schedulers.outsideAngular), switchMap((/** * @param {?} functions * @return {?} */ functions => functions.httpsCallable(name)(data))), map((/** * @param {?} r * @return {?} */ r => (/** @type {?} */ (r.data))))))); return ɵlazySDKProxy(this, functions, zone); } } AngularFireFunctions.decorators = [ { type: Injectable, args: [{ providedIn: 'any' },] } ]; /** @nocollapse */ AngularFireFunctions.ctorParameters = () => [ { type: undefined, decorators: [{ type: Inject, args: [FIREBASE_OPTIONS,] }] }, { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [FIREBASE_APP_NAME,] }] }, { type: NgZone }, { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [REGION,] }] }, { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [ORIGIN,] }] } ]; /** @nocollapse */ AngularFireFunctions.ɵprov = ɵɵdefineInjectable({ factory: function AngularFireFunctions_Factory() { return new AngularFireFunctions(ɵɵinject(FIREBASE_OPTIONS), ɵɵinject(FIREBASE_APP_NAME, 8), ɵɵinject(NgZone), ɵɵinject(REGION, 8), ɵɵinject(ORIGIN, 8)); }, token: AngularFireFunctions, providedIn: "any" }); if (false) { /** @type {?} */ AngularFireFunctions.prototype.httpsCallable; } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class AngularFireFunctionsModule { } AngularFireFunctionsModule.decorators = [ { type: NgModule, args: [{ providers: [AngularFireFunctions] },] } ]; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ export { AngularFireFunctions, AngularFireFunctionsModule, ORIGIN, REGION }; //# sourceMappingURL=angular-fire-functions.js.map