Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Firebase calls as a service

I'm seeking to know what would be best practice, when developing an Angular application with Firebase as a backend. Most tutorials and alike doesn't use firebase calls as a service, but run them directly in the component. Is this how you should handle using firebase in angular? since i'm thinking it would be more usefull to make services to fetch/update certain data on Firebase, since it would be reuseable across multiple components.

also, if you have any litterature or links on using firebase as a service (angular4 with Angularfire2), It would be greatly apprecieated

like image 947
kaspertorp Avatar asked Mar 03 '26 16:03

kaspertorp


1 Answers

Calling the firebase exclusively from services and not directly in the components is definitely a good thing. It will make it easier to maintain your firebase calls and avoid duplicated code. And dependency injection in Angular will help you a lot.

If you want some inspiration you can check out this repository. Have a look at this folder where we have multiple services each responsible for a different part of the data.

like image 166
Jonas Wyss Avatar answered Mar 05 '26 07:03

Jonas Wyss