How to use the @angular/fire._lazySDKProxy function in @angular/fire

To help you get started, we’ve selected a few @angular/fire examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angular / angularfire / src / analytics / analytics.ts View on Github external
@Optional() @Inject(ANALYTICS_COLLECTION_ENABLED) analyticsCollectionEnabled:boolean|null,
    zone: NgZone
  ) {
    const analytics = of(undefined).pipe(
      // @ts-ignore zapping in the UMD in the build script
      switchMap(() => zone.runOutsideAngular(() => import('firebase/analytics'))),
      map(() => _firebaseAppFactory(options, zone, nameOrConfig)),
      map(app => app.analytics()),
      tap(analytics => {
        if (analyticsCollectionEnabled === false) { analytics.setAnalyticsCollectionEnabled(false) }
      }),
      runOutsideAngular(zone),
      shareReplay(1)
    );

    return _lazySDKProxy(this, analytics, zone);
  }
github angular / angularfire / src / remote-config / remote-config.ts View on Github external
const defaultToStartWith = Object.keys(defaultConfig || {}).reduce((c, k) => {
      c[k] = new Value("default", defaultConfig![k].toString());
      return c;
    }, {} as {[key:string]: remoteConfig.Value});

    const mapRemoteConfig = (rc: {[key:string]: Value | remoteConfig.Value}) => {
      const keys = Object.keys(rc);
      return keys.reduce((c, key, index) => {
        const value = rc[key];
        c[index] = new KeyedValue(key, value.getSource(), value.asString());
        return c;
      }, new Array(keys.length));
    }

    const proxy: AngularFireRemoteConfig = _lazySDKProxy(this, remoteConfig, zone);

    this.default$ = of(defaultToStartWith);

    const existing = of(undefined).pipe(
      switchMap(() => proxy.activate()),
      switchMap(() => proxy.getAll())
    );

    let fresh = of(undefined).pipe(
      switchMap(() => proxy.fetchAndActivate()),
      switchMap(() => proxy.getAll())
    );

    this.values = new Proxy(concat(this.default$, existing, fresh), {
      get: (self, name:string) => self[name] || self.pipe(
        map(rc => rc[name] ? rc[name] : undefined),