Skip to content

Commit

Permalink
Format long lines
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 committed Sep 17, 2019
1 parent 4e5754a commit 015b9dc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion notes.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
GET "current" collection from Firestore
"https://firestore.googleapis.com/v1/projects/exchange-rates-adcf6/databases/(default)/documents/current"
https://firestore.googleapis.com/v1/projects/exchange-rates-adcf6/databases/(default)/documents/current
35 changes: 18 additions & 17 deletions src/dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ const COLLECTION_URL =








// STEPS
// 1) Fetch REST data
// 2) Render data
// 3) Import Firebase components
// 3) Dynamically import Firebase components
// 4) Subscribe to Firestore


Expand All @@ -26,13 +24,14 @@ const COLLECTION_URL =


// HTTP GET from Firestore REST endpoint.
fetch(COLLECTION_URL).then(res => res.json())
fetch(COLLECTION_URL)
.then(res => res.json())
.then(json => {
// Format JSON data into a tabular format.
const stocks = formatJSONStocks(json);

// Measure time between navigation start and now (first data loaded)
performance && performance.measure('initialDataLoadTime');
performance && performance.measure("initialDataLoadTime");

// Render using initial REST data.
renderPage({
Expand All @@ -48,22 +47,24 @@ fetch(COLLECTION_URL).then(res => res.json())
});
});








/**
* FUNCTIONS
*/

// Dynamically imports firebase/app, firebase/firestore, and firebase/performance.
function dynamicFirebaseImport() {
const appImport = import(/* webpackChunkName: "firebase-app-dynamic" */ "firebase/app");
const firestoreImport = import(/* webpackChunkName: "firebase-firestore-dynamic" */"firebase/firestore");
const performanceImport = import(/* webpackChunkName: "firebase-performance-dynamic" */"firebase/performance");
const appImport = import(
/* webpackChunkName: "firebase-app-dynamic" */
"firebase/app"
);
const firestoreImport = import(
/* webpackChunkName: "firebase-firestore-dynamic" */
"firebase/firestore"
);
const performanceImport = import(
/* webpackChunkName: "firebase-performance-dynamic" */
"firebase/performance"
);
return Promise.all([appImport, firestoreImport, performanceImport]).then(
([dynamicFirebase]) => {
return dynamicFirebase;
Expand All @@ -79,7 +80,7 @@ function subscribeToFirestore(firebase) {
.onSnapshot(snap => {
if (!firstLoad) {
// Measure time between navigation start and now (first data loaded)
performance && performance.measure('realtimeDataLoadTime');
performance && performance.measure("realtimeDataLoadTime");
// Log to console for internal development
logPerformance();
firstLoad = true;
Expand Down

0 comments on commit 015b9dc

Please sign in to comment.