Firebase-js-sdk: FR: RxFire + Admin SDK

Created on 7 Sep 2018  路  5Comments  路  Source: firebase/firebase-js-sdk

Is RxFire intended to be compatible with the Admin SDK? I know there are some inconsistencies in the API but it would be great if this library could support both.

RxFire feature request

Most helpful comment

Is this still being thought about?

All 5 comments

Hey @adamduren! Since RxFire takes in references you could pass in Admin SDK references that have compatible APIs. However it would likely get a little hairy at times where the API differs.

Could you expand upon your use case? Just so I'm not assuming what you need.

Trying to use rxfire with admin on a simple example of listening to a collection:

const tablesRef = admin.firestore().collection(tables/${this.id}/requests); collection(tablesRef) .subscribe(docs => console.log(docs));

Gives a typescript error of [ts] Argument of type 'CollectionReference' is not assignable to parameter of type 'Query'. Types of property 'firestore' are incompatible. Type 'FirebaseFirestore.Firestore' is not assignable to type 'firebase.firestore.Firestore'. Property 'enablePersistence' is missing in type 'Firestore'.

@moscoso thank you for providing an example. Essentially the web sdk and admin sdk differ in the types they surface and because rxfire references the web sdk it is not usable by the admin sdk. An example in how they differ is the CollectionReference interface. If the web sdk interface contains something that is not in the admin sdk then the admin sdk can not be casted to the type rxfire expects.

Is there a plan for integrating the types between the JavaScript SDK and the Node Admin SDK?

I just posted on Stack Overflow a question related to this issue. I'm trying to write utility functions in TypeScript that can be shared between the client-side and cloud functions code in a React app built using Firebase/Firestore.

It would be useful if the Admin SDK were a superset of the JavaScript SDK and they shared the same types (or the admin types extended from the JavaScript SDK types when adding new functionality, so the latter can be used to create shared functions).

If that isn't possible, a separate "official" adapter or type library which integrates the two libraries would be nice, so there could at least be a common API layer that everyone can code against, rather than each of us developing our own incompatible layers.

Is this still being thought about?

Was this page helpful?
0 / 5 - 0 ratings