pulyaevskiy / firebase-functions-interop

Firebase Functions Interop Library for Dart.
BSD 3-Clause "New" or "Revised" License
191 stars 52 forks source link

firebase_interop package #47

Open m1-nann opened 5 years ago

m1-nann commented 5 years ago

Could we also create firebase_interop package? I am aware there is already the firebase package for Flutter and Web. Though it does not work on node, or planned to focus on node.

One of the reason I would want to have it on node is to write apis for clients that first runs in node before actually get on the browser.

Another reason is that the firebase and firebase-admin libraries share many similarities between then database and firestore. I would suggest to be able to seperate those two from the admin_interop in the future.

This is my use case:

class Context{
  Database realtime;
  Firestore firestore;
}
mixin CartWriter implements Context, NodeBase {
  update(){
    realtime.ref(this.ref).update(this.toJSON);
  }
}

Now if I want to user CartWriter for both server and client, it's a little tricky because it has to distinguish between Database from firebase and one from firebase-admin. One requirement is that the client API cannot import firebase_admin_interop.dart because it includes the require('firebase-admin'), which shouldn't be packaged together in the build.

What do you think?

pulyaevskiy commented 5 years ago

This looks similar to https://github.com/pulyaevskiy/firebase-admin-interop/issues/16

There is definitely a need to unify api interfaces across different platforms which include web, server and Flutter.

It’ll probably require a separate firebase_api package which is used by all platform specific packages to implement actual functionality.

I’d definitely like that. It’s just a matter of finding time for this. (it would also require collaboration across all maintainers if platform specific packages so that generic interface satisfies everyone’s requirements).