angular / angularfire

Angular + Firebase = ❤️
https://firebaseopensource.com/projects/angular/angularfire2
MIT License
7.67k stars 2.19k forks source link

[Feature Request] AngularFire2 + NGRX Data #2078

Closed LanderBeeuwsaert closed 3 years ago

LanderBeeuwsaert commented 5 years ago

Hey team,

I've been reading up on NGRX the last few days. With NGRX 8, it seems ngrx-data would become an integrated part of the ngrx ecosystem.

ngrx-data creates http requests by default through the DefaultDataService (https://next.ngrx.io/guide/data/entity-dataservice#the-defaultdataservice) that is created by the DefaultDataServiceFactory.

It would be great to get an angularFire implementation of this DefaultDataServiceFactory. If I understand correctly, this would make CRUD operations with NGRX and Firestore almost zero-code!

Any plans in that direction? Or is this more something to ask to the firestore and/or ngrx-data teams? I would think that a collaboration would give optimal results?

Just an idea :)

kubk commented 5 years ago

Hi, the idea looks reasonable, but I think it should be implemented in the userland, not in the core library, thus angularfire2 will not depend on NGRX. From my experience, there are many teams that don't use NGRX, and there are a lot of state managers for Angular such as Akita or NGXS. My suggestion is to address this feature request to NGRX team.

jamesdaniels commented 5 years ago

I was rolling around an idea in my head about what state connectors might look in AngularFire v6+... I think it's a different library (ngrx/fire?) but we should do work to enable success, like giving additional fidelity to audit logs & state changes.

I've had hallway discussions with people about this and will continue to, but don't let that stop you if you're interested in pursuing.

LanderBeeuwsaert commented 5 years ago

I certainly agree that it should not be included in the core angularFire library.

Personally, it's just that for the moment, I'm missing 2 things:

  1. a best practice demonstration on how to integrate CRUD with NGRX in angularFire.
  2. In extension, I would assume that one of the most clean ways would be to use ngrx-data.

I didn't really know where to post this, with the NGRX team, the NGRX data team, firebase or angularFire so I though to first post it here and see what that started :).

jamesdaniels commented 5 years ago

Def. I think it's a reasonable documentation ask for now, I'll leave the issue open ;) happy to accept PRs. Also might be a good call for content from @codediodeio

LanderBeeuwsaert commented 5 years ago

I've based my ngrx angularFire authentication integration totally on the fireship example ;), so I was actually indeed looking for something like that about CRUD.

moscoso commented 4 years ago

I'm going to try this in my own app! I think having a DataService that is plug and play for Firebase would open up a lot of possibilities

abcfoundry commented 4 years ago

@moscoso @jamesdaniels @LanderBeeuwsaert - Has anyone tried to make this work? Would be interested if you could share a git. This sound really cool to combine these technologies. Any advice would be helpful.

tim1016 commented 3 years ago

It would be neat thing to have. Currently what I have done to make the two work is override the default data service.

`export class SummaryDataService extends DefaultDataService

{ constructor( http: HttpClient, httpUrlGenerator: HttpUrlGenerator, private credentials: CredentialsService, private readFirestoreDataService: ReadFirestoreDataService, ) { super('Summary', http, httpUrlGenerator); }

getAll() { return this.readFirestoreDataService.getListWithFocus

(this.credentials.collectionPath('summary')); } }` MY opinionated opinion: I am not a big fan of angularFire Documentation, I would rather use the firebase SDK or REST API routes instead.

jamesdaniels commented 3 years ago

Going to close as outdated for now. With vNext I'll likely revamp documentation / guidance on NGRX but going to call out of scope for the 6-series.