forked from FirebaseExtended/emberfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP realtime relationships (FirebaseExtended#594)
* First pass on realtime relationships * Getting everything working decently * Unused variables * Cleanup and PerformanceRouteMixin * Performance monitoring docs
- Loading branch information
1 parent
db079a6
commit 3f23274
Showing
19 changed files
with
282 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { inject as service } from '@ember/service'; | ||
import Mixin from '@ember/object/mixin'; | ||
import { performance } from 'firebase'; | ||
import { Promise, reject } from 'rsvp'; | ||
|
||
export default Mixin.create({ | ||
firebaseApp: service('firebase-app'), | ||
store: service('store') as any, | ||
router: service('router'), | ||
trace: reject() as Promise<performance.Trace>, | ||
init() { | ||
this._super(...arguments); | ||
this.get('firebaseApp').performance(); | ||
// TODO see if I can fix this | ||
if (this.toString().indexOf("@route:application::") > 0) { throw "PerformanceRouteMixin does not work correctly in the application route" } | ||
}, | ||
beforeModel() { | ||
// TODO promise proxy | ||
this.set('trace', this.get('firebaseApp').performance().then(perf => { | ||
const trace = perf.trace(`${this.toString()}:didTransition`); | ||
trace.start(); | ||
return trace; | ||
})); | ||
}, | ||
afterModel() { | ||
const tracePromise = this.get('trace')!; | ||
const router = this.get('router'); | ||
tracePromise.then((trace:performance.Trace|undefined) => { | ||
// TODO figure out how to disconnect the routeDidChange listener | ||
router.on('routeDidChange', () => { | ||
if (trace) { | ||
const screen_name = router.currentRouteName; | ||
trace.putAttribute('url', router.currentURL); | ||
(trace as any).name = `${screen_name}:didTransition`; | ||
trace.stop(); | ||
this.set('trace', reject()); | ||
trace = undefined; | ||
} | ||
}); | ||
}) | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Mixin from '@ember/object/mixin'; | ||
declare const _default: Mixin<{ | ||
firebaseApp: import("@ember/object/computed").default<import("../services/firebase-app").default, import("../services/firebase-app").default>; | ||
router: import("@ember/object/computed").default<import("@ember/routing/router-service").default, import("@ember/routing/router-service").default>; | ||
init(): void; | ||
}, import("@ember/object").default>; | ||
export default _default; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
import Route from '@ember/routing/route'; | ||
import RealtimeRouteMixin from 'emberfire/mixins/realtime-route'; | ||
import { inject as service } from '@ember/service'; | ||
import PerformanceRouteMixin from 'emberfire/mixins/performance-route'; | ||
|
||
export default Route.extend(RealtimeRouteMixin, { | ||
export default Route.extend(RealtimeRouteMixin, PerformanceRouteMixin, { | ||
firebaseApp: service(), | ||
model() { | ||
return this.firebaseApp.auth().then(({currentUser}) => | ||
currentUser && | ||
this.store.query('comment', { filter: { user: currentUser.uid }, include: 'user' }) || | ||
this.store.query('comment', { include: 'user'} ) | ||
this.store.query('comment', { filter: { user: currentUser.uid } }) || | ||
this.store.query('comment', { } ) | ||
); | ||
} | ||
}) |
Oops, something went wrong.