From 015b9dc4c3b1c91016af000368ff612d34c9a5f3 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Tue, 17 Sep 2019 11:50:14 -0700 Subject: [PATCH] Format long lines --- notes.txt | 2 +- src/dynamic.js | 35 ++++++++++++++++++----------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/notes.txt b/notes.txt index fbf275e..65e390b 100644 --- a/notes.txt +++ b/notes.txt @@ -1,2 +1,2 @@ GET "current" collection from Firestore -"https://firestore.googleapis.com/v1/projects/exchange-rates-adcf6/databases/(default)/documents/current" \ No newline at end of file +https://firestore.googleapis.com/v1/projects/exchange-rates-adcf6/databases/(default)/documents/current diff --git a/src/dynamic.js b/src/dynamic.js index cdded8c..bea7211 100644 --- a/src/dynamic.js +++ b/src/dynamic.js @@ -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 @@ -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({ @@ -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; @@ -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;