From 1bb09fe77fa7a2fc8bbd6bbd33bcc25b238878ab Mon Sep 17 00:00:00 2001 From: kor Date: Tue, 6 Nov 2018 04:38:56 +1300 Subject: [PATCH] Add continued failed messy testing of promises and smooth article adding. --- docs/logic/main.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/docs/logic/main.js b/docs/logic/main.js index b54f5b3..5f21cde 100644 --- a/docs/logic/main.js +++ b/docs/logic/main.js @@ -47,21 +47,27 @@ function Main() console.log(Date.now() + ' - db ready'); // console.log(db); + + + setTimeout(() => { let dbKeys = Object.keys(db); let i = 0; - let contentHtml = ''; - while (i < dbKeys.length) + + console.log(Date.now() + ' - start render'); + + while (i < 200)//dbKeys.length) { - contentHtml += this.grid.buildArticle(db[dbKeys[i]], dbKeys[i]); + document.querySelector('main').innerHTML += this.grid.buildArticle(db[dbKeys[i]], dbKeys[i]); + console.log(Date.now() + ' - did one! LAAAAAAG while reflowing'); i++; } - - return contentHtml; - }) - .then((html) => { - console.log(Date.now() + ' - html ready'); - document.querySelector('main').innerHTML = html; - console.log(Date.now() + ' - rendered!'); + + console.log('COMPLETED ALL ARTICLES - lag stops') + return 'done'; + }, 2000); + + + }) .catch((error) => { console.log('ERROR:', error);