Nativescript-plugin-firebase: AngularFire2 Support - How do I get a hold of the User interface?

Created on 27 Sep 2018  路  10Comments  路  Source: EddyVerbruggen/nativescript-plugin-firebase

It's located here:
https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/c543b539771b1996bb1a6d81e4191f681d0ba516/src/platforms/web/typings/firebase-webapi.d.ts#L36

import * as firebase from 'nativescript-plugin-firebase/app' doesn't seem to contain that interface.

Most helpful comment

Godspeed to you!

I'm here to assist if you need anything.

All 10 comments

That typings file should not be used. I use it during plugin development to try and keep the plugin interface as close as possible to that reference.

Try this one: import { User } from "nativescript-plugin-firebase";

Thanks for the snappy response.

Let me elaborate what I'm working on. I'm trying to bridge AngularFire2 and your delicious plugin. But there are inconsistencies in the API's. F.ex the User in import { User } from "nativescript-plugin-firebase"; is incompatible with https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/c543b539771b1996bb1a6d81e4191f681d0ba516/src/platforms/web/typings/firebase-webapi.d.ts#L36

Ah yes, I always wanted to do that as well but never got around to it. Happy to see you're trying to do it!

The first step I had to take was making a 'web api' version of the plugin, because as you know AF2 builds on top of that. The web api-compatible interfaces live in https://github.com/EddyVerbruggen/nativescript-plugin-firebase/tree/master/src/app, but you're right, the User itself has not yet been aligned. Do you think you can align it with the web api where needed while maintaining backward compatibility? I hate breaking it because it'll lead to a ton of issues, even with semver, docs and demos..

We're in the middle of converting a rather big Angular project to NativeScript, and it is pretty dependent on AF2. I've tasked myself with figuring out the leanest way to get our database layer working again, and it's either refactoring out AF2, or making it support your plugin (I'm fond of the latter idea).

I haven't decided what route I'm taking yet (need to decipher the workload involved), but if I go down this route, I'll do whatever it takes to maintain backwards compatibility while bringing the API up to date.

Godspeed to you!

I'm here to assist if you need anything.

So I've been trying to get AF2 working.

Main obstacles:

  • AF2 uses a lot of interfaces which have no equivalent in NPF yet. So it would either require a lot of work in NPF, or changing AF2 to use the current NPF interface.
  • AF2 uses rollup-js and has a 350 line build script, which I expect would be a headacre.

Has aligning the Web API with the official WebSDK that Google supplies by using all their interfaces, been considered? (proxy pattern basically)

An example would be:
npm i firebase --save-dev;

file: app/index.ts

import * as firebase from 'firebase/app';

export class User implements firebase.User {
   get uid() {
      // code to get the uid from the respective platform
   }

   linkWithRedirect(provider: firebase.auth.AuthProvider): Promise<void> {
    throw new Error('Method not supported.');
  }

   // ... etc
}

So whatever API Google puts out or changes; we'd be forced to adopt those changes, which would make implementing things like AF2 much simpler (or any other plugin that uses the web SDK).

It might even give the added benefit of being able to use all of the tests that Google has already written for the web SDK.

It's not a small task I know, but you have already made a lot of code for each respective platform.

I always wanted to get around to this too. Not sure I'd be much help, but would love to lend a hand where I could.

I have a working prototype at work; but I wouldn't call it production ready.

@larssn Is there any chance we could get a peak at the working prototype?

@BrianChapman It's too rough atm. The only thing that works is Firestore support, and basic Auth support (Auth in ongoing, just did a related PR: https://github.com/EddyVerbruggen/nativescript-plugin-firebase/pull/1052).

These are the only two working modules yet. I'm probably not going to convert all of AF2; I'll start with what my business needs.

I'll create a public AF2 (alpha) branch soon, I'll post here when I do.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jlooper picture jlooper  路  3Comments

yencolon picture yencolon  路  4Comments

thunder413 picture thunder413  路  3Comments

andrewexton373 picture andrewexton373  路  4Comments

bunower picture bunower  路  3Comments