singpath / classmentors

Class Mentors UI
http://www.classmentors.com
MIT License
0 stars 8 forks source link

Firebase 3 #73

Closed dinoboff closed 8 years ago

dinoboff commented 8 years ago

Firebase 3 relies on App which encapsulate a connection to a firebase app (allows multiple connection to different app or with deferent auth). Instead of various intermediary services between our datastore services and the firebase client, the angular app simply require a "firebaseApp" constant, which is easy to mock in test.

We can remove most firebase related services; no more spfFirebaseRef or spfFirebase.

One issue, is that the requests are no longer logged to the console.

singpath-core API changes:

OtherspfAuth method and spfAuthdata are unchanged.

TODO:

SingaporeClouds commented 8 years ago

Console errors Running with npm start after npm install and npm test. image

Console errors after running npm build and npm run serve-build image

dinoboff commented 8 years ago

It's a work in progress; only src/packages/singpath-core as been migrated (this is were spfFirebaseRef and spfFirebase.

Only singpath-core demo is completed:

cd src/packages/singpath-core
npm install
npm start
dinoboff commented 8 years ago

@SingaporeClouds @shiquan-lim It's ready for review.

When will it be suitable to merge? It might disrupt some PR in progress.

dinoboff commented 8 years ago

@SingaporeClouds @shiquan-lim

Rebased on last PR.

I will merge this PR once I document firebase angularFire setup on example app.

ps: this PR fails coverage check since it's adding all the code base to coverage, but I set coveralls to only report any decrease in coverage while the coverage is so low.

coveralls commented 8 years ago

Coverage Status

Coverage decreased (-92.3%) to 7.697% when pulling 6bf0d14ce2a18a7d9883366d5a79502db525c06b on dinoboff:firebase-3 into 3621fe21e41b28f57f4d98a89f0c7b6f7fdbf208 on singpath:master.

dinoboff commented 8 years ago

@SingaporeClouds @shiquan-lim

PR replaces:

var db = firebaseApp.database();
var ref = db.ref(`path/to/${someId}}`);
var db = firebaseApp.database();
var ref =  db.ref(`path/to/${someId}}`);
var obj = $firebaseObject(ref);

obj.$loaded().then(() => dosomething(obj);

No more intermediary services; we are now using firebase reference directly. Here is a guide for the for migrated code from firebase 2 to firebase 3 sdk.

The PR also create an index of component that the main module loads instead of each component individually.

Finally, In a few cases I used someRef.once() instead of creating a synchronized firebase object because the data needed to be read only once.

One change I didn't notice is that the initial value of $firebaseAuth.$getAuth() always returns null initially.

in #95, I added spfAuth.$loaded() to deal with it; a few view loading logic had to be adjusted.