Giter Site home page Giter Site logo

Comments (14)

vzsolt1981 avatar vzsolt1981 commented on May 27, 2024 3

Hi @vzsolt1981 , that would be worth tryin actually. Thanks, I could try it.

Works for me, hence the suggestion. Good luck!

How did you actually do it? I have been playing with it a bit, but just adding ZoneJS to @angular/fire did not work - I guess I have to re-build angular/fire again?

In the zones.d.ts, NgZone is imported from @angular/core - how did you deal with all this? Thanks

I'm not sure about your approach, it's 2 changes you have to make as per my initial suggestion:

  1. Add (or leave it there) zone.js to polyfills in your app's angular.json (w/o nx) or project.json (w nx):

"polyfills": ["zone.js"],

  1. Add zoneless change detection provider to your app's app.config.ts:
import {
  ApplicationConfig,
  ɵprovideZonelessChangeDetection as provideZonelessChangeDetection,
} from '@angular/core';

export const appConfig: ApplicationConfig = {
  providers: [
    ...,
    provideZonelessChangeDetection(),
  ],
};

from angularfire.

spock123 avatar spock123 commented on May 27, 2024 2

This is super important, we're about to go zoneless for our app but this is blocking us, unfortunately.

from angularfire.

eneajaho avatar eneajaho commented on May 27, 2024 2

Hi @vzsolt1981 , that would be worth tryin actually. Thanks, I could try it.

Works for me, hence the suggestion. Good luck!

How did you actually do it? I have been playing with it a bit, but just adding ZoneJS to @angular/fire did not work - I guess I have to re-build angular/fire again?
In the zones.d.ts, NgZone is imported from @angular/core - how did you deal with all this? Thanks

I'm not sure about your approach, it's 2 changes you have to make as per my initial suggestion:

  1. Add (or leave it there) zone.js to polyfills in your app's angular.json (w/o nx) or project.json (w nx):

"polyfills": ["zone.js"],

  1. Add zoneless change detection provider to your app's app.config.ts:
import {
  ApplicationConfig,
  ɵprovideZonelessChangeDetection as provideZonelessChangeDetection,
} from '@angular/core';

export const appConfig: ApplicationConfig = {
  providers: [
    ...,
    provideZonelessChangeDetection(),
  ],
};

Can confirm this works well for the moment!

Thanks 🤩

from angularfire.

RobbyRabbitman avatar RobbyRabbitman commented on May 27, 2024 1

If your app only uses the DI feature of angular/fire, you can build your own providers e.g like that:

import { FirebaseApp, FirebaseOptions, initializeApp } from 'firebase/app';
import { Auth, connectAuthEmulator, getAuth } from 'firebase/auth';
import {
  Firestore,
  connectFirestoreEmulator,
  getFirestore,
} from 'firebase/firestore';
import { createNoopInjectionToken } from 'ngxtension/create-injection-token';

export const [firebaseApp, provideFirebaseApp] =
  createNoopInjectionToken<FirebaseApp>('[Firebase] App');

export const [firestore, provideFirestore] =
  createNoopInjectionToken<Firestore>('[Firebase] Firestore');

export const [firebaseAuth, provideFirebaseAuth] =
  createNoopInjectionToken<Auth>('[Firebase] Auth');

export interface FirebaseConfig {
  options: FirebaseOptions;
  features?: Partial<{
    auth: {
      emulators?: { host: string; port: number };
    };
    firestore: {
      emulators?: { host: string; port: number };
    };
  }>;
}

export function provideFirebase({ options, features }: FirebaseConfig) {
  const app = initializeApp(options);
  const providers = [provideFirebaseApp(app)];

  for (const feature in features) {
    switch (feature) {
      case 'auth': {
        const auth = getAuth(app);
        providers.push(provideFirebaseAuth(auth));

        const emulators = features[feature]?.emulators;

        if (emulators) {
          connectAuthEmulator(
            auth,
            `http://${emulators.host}:${emulators.port}`,
          );
        }

        break;
      }
      case 'firestore': {
        const firestore = getFirestore(app);
        providers.push(provideFirestore(firestore));

        const emulators = features[feature]?.emulators;

        if (emulators) {
          connectFirestoreEmulator(firestore, emulators.host, emulators.port);
        }

        break;
      }
    }
  }

  return providers;
}

from angularfire.

lazmeister avatar lazmeister commented on May 27, 2024 1

Unfortunately it seems this project is kinda dead-ish, anyone knows if we can use Angular without @angular/fire, and still use Firebase?

You definitely can, if this project doesn't get support we might be heading that way too (Angular with firebase)

from angularfire.

spock123 avatar spock123 commented on May 27, 2024 1

@Meistercoach83 not been able to work on it yet but I don't think there's any issue using the Native firebase library. We use Auth a lot so that part will have to be a bit re-written, as we have used the observable parts as integration with Ngrx/Store.

When I get time and if I make it work I'll make sure to post it here. It's a pity, I really like @angular/fire

from angularfire.

google-oss-bot avatar google-oss-bot commented on May 27, 2024

This issue does not seem to follow the issue template. Make sure you provide all the required information.

from angularfire.

vzsolt1981 avatar vzsolt1981 commented on May 27, 2024

As a workaround, you could provide zoneless change detection for Angular itself and leave zone.js in polyfills for Fire, until it gets sorted out.

from angularfire.

spock123 avatar spock123 commented on May 27, 2024

Hi @vzsolt1981 , that would be worth tryin actually. Thanks, I could try it.

from angularfire.

vzsolt1981 avatar vzsolt1981 commented on May 27, 2024

Hi @vzsolt1981 , that would be worth tryin actually. Thanks, I could try it.

Works for me, hence the suggestion. Good luck!

from angularfire.

spock123 avatar spock123 commented on May 27, 2024

Hi @vzsolt1981 , that would be worth tryin actually. Thanks, I could try it.

Works for me, hence the suggestion. Good luck!

How did you actually do it?
I have been playing with it a bit, but just adding ZoneJS to @angular/fire did not work - I guess I have to re-build angular/fire again?

In the zones.d.ts, NgZone is imported from @angular/core - how did you deal with all this?
Thanks

from angularfire.

spock123 avatar spock123 commented on May 27, 2024

Ahh thanks guys. I had totally removed zonejs in the app. So I guess leave that in polyfills (too bad) but disable it in the config (good).

Cheers

Update: it works, thanks for all the good advice

Update2: it works yes, but it breaks if you are using other libraries that now think ZoneJS provides change detection, which is doesn't. Example: ngx-toastr now thinks ZoneJS exists (it checks I guess) and tries to use that, with an error to follow.

Unfortunately it seems this project is kinda dead-ish, anyone knows if we can use Angular without @angular/fire, and still use Firebase?

from angularfire.

Meistercoach83 avatar Meistercoach83 commented on May 27, 2024

@spock123 did you find a solution?

from angularfire.

Meistercoach83 avatar Meistercoach83 commented on May 27, 2024

@jamesdaniels is this project dead?

from angularfire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.