How to use the angularfire2.FirebaseZoneScheduler function in angularfire2

To help you get started, we’ve selected a few angularfire2 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 / database-deprecated / firebase_list_factory.ts View on Github external
});
    handles.push({ event: 'child_changed', handle: chgFn });

    return () => {
      // Loop through callback handles and dispose of each event with handle
      // The Firebase SDK requires the reference, event name, and callback to
      // properly unsubscribe, otherwise it can affect other subscriptions.
      handles.forEach(item => {
        ref.off(item.event, item.handle);
      });
    };

  });

  // TODO: should be in the subscription zone instead
  return observeOn.call(listObs, new FirebaseZoneScheduler(new NgZone({}), {}));

}
github angular / angularfire / src / auth / auth.ts View on Github external
constructor(
    @Inject(FirebaseAppConfig) config:FirebaseOptions,
    @Optional() @Inject(FirebaseAppName) name:string,
    private zone: NgZone
  ) {
    const scheduler = new FirebaseZoneScheduler(zone);
    this.auth = zone.runOutsideAngular(() => {
      const app = _firebaseAppFactory(config, name);
      return app.auth();
    });

    this.authState = scheduler.keepUnstableUntilFirst(
      scheduler.runOutsideAngular(
        new Observable(subscriber => {
          const unsubscribe = this.auth.onAuthStateChanged(subscriber);
          return { unsubscribe };
        })
      )
    );

    this.idToken = scheduler.keepUnstableUntilFirst(
      scheduler.runOutsideAngular(
github angular / angularfire / src / firestore / firestore.ts View on Github external
constructor(
    @Inject(FirebaseAppConfig) config:FirebaseOptions,
    @Optional() @Inject(FirebaseAppName) name:string,
    @Optional() @Inject(EnablePersistenceToken) shouldEnablePersistence: boolean,
    zone: NgZone
  ) {
    this.scheduler = new FirebaseZoneScheduler(zone);
    this.firestore = zone.runOutsideAngular(() => {
      const app = _firebaseAppFactory(config, name);
      return app.firestore();
    });

    this.persistenceEnabled$ = zone.runOutsideAngular(() => {
      return shouldEnablePersistence ?
        from(this.firestore.enablePersistence().then(() => true, () => false)) :
        from(new Promise((res, rej) => { res(false); }));
    });
  }