New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release Candidate API proposal! Breaking changes please read! #854
Comments
Would you also entertain the refactoring of the When composing RxJS observables, in many situations the Something similar was dismissed in this issue as not adding value over the SDK methods. However, after working with an RxJS/ngrx-based application I don't believe that's the case and AngularFire2's not having an observable that allows working with added, removed and changed items just means that everyone has to write their own. I've had to. |
I like this! Modularity is key and will be a huge improvement in reducing bundle sizes and boot times. Just that is already worth as many breaking changes as needed.
Agreed. The least the library does, the better. If it's not specific to Angular then it should be done directly via the SDK or through some other library. About auth, not much to add. Besides wrapping auth state changes in an observable, everything else can be done directly on the SDK. Just some bikesheding: About versioning:
Does that mean maintaining version parity with Angular in the future? Because that wouldn't really be using semver, if AF bumps minor version without any new features, or major versions without actually introducing any breaking changes. If parity is not the goal here, then AngularFire2 3.0 might be more appropriate (I know, I know... more bikeshedding). As for all the new features planned for the future: yes please, but only if they make sense in an Angular environment. About "Authentication Route Guards": OMG YES. Last So instead of having just the import { AngularFireModule, AngularFireApp } from 'angularfire2';
import { AngularFireDatabaseModule, AngularFireDatabase } from 'angularfire2/database';
import { AngularFireAuthModule, AngularFireAuth } from 'angularfire2/auth'; We could have separate packages for each functionality like import { AngularFireModule, AngularFireApp } from '@angularfire/app';
import { AngularFireDatabaseModule, AngularFireDatabase } from '@angularfire/database';
import { AngularFireAuthModule, AngularFireAuth } from '@angularfire/auth'; Also... two birds, one stone, right? ;) |
#itJustAngularFire :-) But seriously: I love the focus on the code size and modularity. I think this is awesome. What I don't see, is discussion about TypeScript version used to produce the PS: if you are going break all this stuff, please make sure you document the migration path. These changes while painful are very much necessary, and having good documentation makes the pain hurt less. PS2: if you are going to break all this stuff, then just rename the thing to |
@cartant I'm definitely interested in this idea. If you'd like to create an issue with a proposal, I'd love to discuss it. @jsayol Upon much thought, I'd like to stick to Also I have given serious thought to scoped packaged, I even own the angularfire npm user account. I've been warned by many people smarter than I to avoid scoping packages unless it's completely necessary. I'm still going to do more research, but I do think the time would be now if we were to make that change. @IgorMinar Thanks for the feedback! I neglected to focus on upgrading TypeScript, but I definitely agree it should be a priority with this release. Yes there will be a clear migration path. For Database users there will be only small changes. For authentication I will provide the analogous methods in the Firebase SDK. As for versioning, we can't change the name to |
@davideast I'm curious as to what the potential problems are with the scoped names. I think that using the Hopefully, using multiple, scoped packages won't impose too much of an administrative burden. |
@davideast @cartant creating several packages (scoped or not) from a single repo is quite easy using a tool like Lerna. I just went through that process myself and it's straightforward to set up. Those who advised against it, did they give any specific reasons? I'm actually quite interested here. Just because I gave this some more thought, I'll reiterate: don't jumpt to v4. I think the best course of action would be to:
I'm conflicted about AngularFire exposing the child added/removed/etc as observables. On one hand that's something I always end up doing myself whenever working with Firebase and RxJS so I see some merit as to why it'd be useful to have, but that's not something you might consume directly on the template to update the UI. So this wouldn't really be about Angular but just about providing handy observables to the underlying SDK events, and isn't that the kind of approach the new API is trying to get rid of? I don't feel too strongly about it either way, though, and if it gets added people will definitely use it. |
@jsayol @davideast I'll create an issue for the list refactoring sometime soon. It's less about exposing BTW, I use AngularFire2 extensively, and nowhere do I directly use an AngularFire2 observable in a template. |
If you're worried about semver collisions, just give yourself a big enough buffer that it won't be an issue. Go to plaid and skip all the way to version 10 and you won't be stuck with the numbered I don't think matching Angular at version 4.0 holds any value. Their release schedule will leave AF in the dust soon enough. That said, I like the look of the scoped package. |
I like the idea of less code in angularfire2, just to make it easier to follow along with firebase releases, and their docs are a lot more comprehensive than yours. I do not like the idea of jumping to 4.0 if you're not going to keep version parity with angular. And I don't feel like keeping version parity with angular would give much of a benefit, but it doesn't really matter all too much in the end. I also think that putting angularfire2 in either Compare to @angular/material, their naming/packaging scheme makes perfect sense. |
Can you put also a method that tells if the user is connected or not (not to confuse with the login)? that will be great |
I like the idea of breaking up AngularFire2 into smaller modules. The breaking changes do not seem to be like they will be much of a pain as long as you have clear documentation. I think many of us are only Injecting Auth and Database in our services. Removing some of the wrapper functions are also a great idea, it'll force us to learn more from the SDK itself, which is necessary to get a complete user experience. What I'm really looking forward to is the documentation, specifically best practices. I'd love us to have somewhere to talk about and share exactly how we're using AngularFire2 in order to help develop those practices. It would be nice to get to a point where some of us are sharing modules that we can drop into our projects and build upon. Are you using stores? How are you building them to work with AF? (Just a couple rhetorical questions) |
Evolution is happening! Ionic 2 [final] has only been out for 2 months, Angular 4.0 dropped a few weeks ago, and today the first Ionic 3.0 beta was released. There is a clear need for AngularFire to evolve too. I fully support your proposed changes. I love using AngularFire's bindings for a few specific 'live-data' needs, but most of the data my apps are loading are 'one-time' loads. So most of the time, I'm using firebase's snapshots to pull data. Please move forward! Thank you! |
@albanx If you want an observable that emits a
I don't think there's much to be gained by wrapping anything around that. |
Can we get an update on this topic, please? |
Just going to throw in my hat of support, this all sounds great. I would like to also see what the effort is to try and stay as current as possible on @angular. angularfire2 is still on 2.0.0 which is causing some issues with the latest cli as mentioned elsehwere and strikes me as though it could be an ongoing problem as @angular cruises through semvar. |
Redirect was only sending the user:email scope to GitHub even when requesting repo. As per angular/angularfire#798 this does not happen when using popup. However, the accessToken isn't visible in the observable of auth states, but is in the promise returned from login. Given the impending RC of AngularFire2 will require reworking of the auth code (see angular/angularfire#854), this will do for now.
@elekzalan @myspivey The first
|
Loaded and so far so good! Did not have Auth in this simple little POC so unable to test that but the breakout is great, simplified our code a bit. Great work! Will report back if I run into any issues. |
Tried migration my smallish app that uses db and Auth, and apart from spending some time reworking the Authentication (it's much easier to link accounts now) it was completely painless. Looking great! |
// Md => Material design
import {
MdButtonModule,
MdCheckboxModule,
MdSelectModule,
MdInputModule,
MdSnackBarModule
} from '@angular/material';
// Scope: `@angular`
import { AngularFireAppModule } from '@angular/firebase-app';
import { AngularFireDatabaseModule } from '@angular/firebase-database';
import { AngularFireAuthModule } from '@angular/firebase-auth';
// Fa => Firebase application
import {
FaAppModule,
FaDatabaseModule, Database, ListFactory
FaAuthModule, Auth, AuthProviders
} from '@angular/firebase'; // Can it be tree-shaking? |
Regarding the version, AngularFire2 maybe can be AngularFireX if you can't rename AngularFire to AngularFireJS, at least for now, one step then you can maybe after a while to rename the AngularFire to JS version. I see most of the modules did that, it will make sense for now I think. BTW, the rc0 version is really nice, I feel that while I was migrating :) |
anybody can give me an example how to do the googleprovider or facebookprovider login now? thank you :) |
@s3ppo just follow the firebase docs but replace constructor(private fbAuth: AngularFireAuth) {
this.fbAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
} |
@Maistho |
@s3ppo You have to use FirebaseApp; like this example:
|
getting No Provider for AngularFireAuth during run time.. not sure what i missed. added authservice in the app module providers |
@exxmen you need to import:
inside your module, for instance, app.module.ts |
Hi, |
You need to import |
Copied some material from angular#854 into this doc
thanks @almothafar also had to include all the imported ionic-natives (Facebook, GooglePlus, etc.) to the providers in appmodule. |
* Add information about individual @ngModules Copied some material from #854 into this doc * add comments based on feedback
It has been merged and released! |
Just updated to this, was easy as cake, and works like a charm!, thanks for your great job! |
@davideast I am having a similar problem can you please help me fix. I am like struggling because of this. [23:00:27] typescript: C:/Users/Harsha Varun/MyIonicProject/src/pages/third/third.ts, line: 4 L3: import {FourthPage} from '../fourth/fourth'; L3: import {FourthPage} from '../fourth/fourth'; L3: import {FourthPage} from '../fourth/fourth'; Thanks in advance |
@harshavarun25 you really should read migration steps, also, you reached this issue, you can find the solution with comments as well. |
@harshavarun25 read the migration & docs, as @almothafar said. But on top of that, don't spam the repo in three--separate--places. |
@raugaral This is the wrong place to ask that question. |
* Add information about individual @ngModules Copied some material from angular/angularfire#854 into this doc * add comments based on feedback
* Add information about individual @ngModules Copied some material from angular/angularfire#854 into this doc * add comments based on feedback
Release Candidate API Proposal
Please read and leave feedback!
AngularFire2 is almost ready for its first semver release! Before that can happen, a few problems must be addressed.
Removing
AngularFire
for ModularityAngularFire2 does not take advantage of the Firebase SDK's modularity. Users who only need authentication receive database code and vice versa. The
AngularFire
service is a central part of this problem. The class includes each feature whether you are using it or not. Even worse, this cannot be tree-shaken. As the library grows to include more features, this will only become more of a problem.The way to fix this is to remove the
AngularFire
service and break up the library into smaller@NgModule
s.AngularFireModule
(Firebase app only)AngularFireAuthModule
AngularFireDatabaseModule
AngularFireStorageModule
(Future release)AngularFireMessagingModule
(Future release)This will allow you to get the code for only what features you need. Below is an example setup:
Instead of pulling each feature off the
AngularFire
service, you now import each feature module.Breaking: Simplified Authentication API
The goal of AngularFire (1 & 2) is not to wrap the Firebase SDK. This is something I wrote in a blog post way back in 2014 about AngularFire 0.8.
The goal is to provide Angular-specific functionality. We've done this with
FirebaseListObservable
and its advanced querying techniques, but the current authentication API offers little outside of the Firebase SDK. The Authentication API also requires the most maintenance as it has quirks across different browsers and platforms like Cordova. Wrapping the API puts AngularFire2 in the middle of these changes, make it prone to break.My solution is to simplify the API. This, however, means breaking changes. Below is the proposed API and an example:
The
authState
observable is the best candidate for Angular-specific functionality. The rest of the methods are removed.This proposal removes custom methods like
.createUser()
. Most of the custom authentication methods were simply wrapper calls around the official SDK. Rather than creating more bytes for no value, the Firebase Auth instance is available as a property namedauth
where the same functionality exists.Remove pre-configure login
This change also removes pre-configuring login. Pre-configuring is a convenient feature, but this API has introduced a fair amount of complexity into the codebase for fairly low value. This is another decision to forgo minor conveniences for simplicity and less code.
I understand that this is likely the hardest of all the breaking changes, so I am open to suggestions. However, I want to keep to the ideals that AngularFire2 is not a wrapper.
We also have plans for authentication based route guards, but more research is needed before we have an API.
Breaking: FirebaseListFactory and FirebaseObjectFactory only take in a Database Reference
This change only affects a few users who directly use
FirebaseListFactory
. Most people injectAngularFireDatabase
directly or use theAngularFire
service.If you directly use
FirebaseListFactory
you will no longer be able to pass in a string. **TheAngularFireDatabase
service will still take paths for.list()
and.object()
. With the FirebaseApp now easily injectable, you can create a reference while still adhering to DI.This is a minor change, but again it prioritizes simplicity. It keeps the library from writing check logic at multiple abstractions. This again reduces complexity and maintenance.
Below is an example:
Semver: AngularFire2 4.0
Let's talk about naming. AngularFire2 is the second AngularFire. It's not "AngularFire" for Angular 2. Now, I'll admit, this isn't ideal for a name. However, we can't rename the original AngularFire to AngularFireJS. There are many people with AngularFire apps in production and we do not have to cause a problem over vanity.
When we release the semver version will be AngularFire2 4.0.
When the breaking changes are implemented, AngularFire2 will enter version
rc0
. Once enough adoption and feedback have been received (and bugs fixed), will release to 4.0.We are investigating scoped packaging to get
@angularfire/core
,@angularfire/database
,@angularfire/auth
, and etc. However, there are draw backs to maintaining several scoped packages, such as handling several version mismatches.Post 4.0
After 4.0 we'll focus on features. Here are the items on the docket:
Conclusion: Sticking to a principle
This is a big change. But this change brings several new benefits, and most importantly a guiding principle for AngularFire2. AngularFire2 is not a wrapper around the Firebase SDK. AngularFire2 integrates Firebase into Angular-specific features. If the solution is a simple function wrap, then it doesn't fit the principle.
Your feedback is not only welcome, but it is necessary in making AngularFire2 the best Firebase and Angular experience possible.
The text was updated successfully, but these errors were encountered: