Extended Angular Firestore

#1

I had fun publishing my previous npm library, so I figured why not contribute another one to the open source world. Honesty, I’m not sure if this is a good thing, or just a bit of vanity, because the whole “library” is less than 100 lines of code. But I wrote it because it helped me, so maybe it will help somebody else. If you try it out, do please let me know if you run into an issue.

Ok, to business:

Extended Angular Firestore
Lightweight extension of Angular Firestore. Provides a more intuitive API. Create, Update, Insert-or-Update (Upsert), Check for Existence, Download Once, Download and listen for changes.

Github link
npmjs link

The goal of the API is to help the programmer manage Observable Subscriptions, so you only ask for exactly what you want. You can either ask to download a document or a collection exactly once, in which case you get back a Promise that resolves to the value of the document you are requesting. Or you can listen to a document or a collection, in which case you get back an Observable you can subscribe to (and might have to unsubscribe from). This structure has helped me avoid annoying double-request errors where I failed to unsubscribe from a stream I hadn’t realized I was still subscribed to.

This package also handles existence/nonexistence gracefully, which has been a weakness of both Firebase and Firestore in the past. To create or modify a document, simply use the Upsert method, which does the existence checking for you.

Finally, the API extension is lightweight – about 100 lines of TypeScript and three RXJS operators (which AngularFire may already need).

Do we need Angularfire2?
#2

This is what I got after installation:

Uncaught (in promise): Error: StaticInjectorError(AppModule)[AngularFireAuth -> InjectionToken angularfire2.app.options]: 
  StaticInjectorError(Platform: core)[AngularFireAuth -> InjectionToken angularfire2.app.options]: 
    NullInjectorError: No provider for InjectionToken angularfire2.app.options!
Error: StaticInjectorError(AppModule)[AngularFireAuth -> InjectionToken angularfire2.app.options]: 
  StaticInjectorError(Platform: core)[AngularFireAuth -> InjectionToken angularfire2.app.options]: 
    NullInjectorError: No provider for InjectionToken angularfire2.app.options!
    at _NullInjector.get (http://localhost:8100/build/vendor.js:1377:19)
    at resolveToken (http://localhost:8100/build/vendor.js:1675:24)
    at tryResolveToken (http://localhost:8100/build/vendor.js:1617:16)
    at StaticInjector.get (http://localhost:8100/build/vendor.js:1485:20)
    at resolveToken (http://localhost:8100/build/vendor.js:1675:24)
    at tryResolveToken (http://localhost:8100/build/vendor.js:1617:16)
    at StaticInjector.get (http://localhost:8100/build/vendor.js:1485:20)
    at resolveNgModuleDep (http://localhost:8100/build/vendor.js:11270:25)
    at _createClass (http://localhost:8100/build/vendor.js:11315:32)
    at _createProviderInstance$1 (http://localhost:8100/build/vendor.js:11281:26):8100/build/vendor.js:11281:26)
#3

Just copypaste it into your project if you’d like to use it. I’ll rework the injector now that Ionic 4 is out, but I have a couple other things I need to finish first, so it might be a while. More generally, I might not be providing any support to my npm packages until toward the end of the year, once I finish the Big Thing™.