Commit fb0788760b2ce15437b50ead1e804b650cc19077
disable debounce to prevent stacking of "load-content" effect on blogIndex
mix irving committed on 11/28/2017, 1:05:28 AMParent: 34736f8234e840203c81e10a3b49e1570aa2a801
Files changed
app/html/app.js | changed |
app/page/blogIndex.js | changed |
app/html/app.js | ||
---|---|---|
@@ -21,8 +21,9 @@ | ||
21 | 21 | var view = Value() |
22 | 22 | var app = h('App', view) |
23 | 23 | api.history.obs.location()(renderLocation) |
24 | 24 | function renderLocation (loc) { |
25 | + console.log('rendering new view', loc) | |
25 | 26 | var page = api.router.sync.router(loc) |
26 | 27 | if (page) view.set([ |
27 | 28 | api.app.html.header({location: loc, push: api.history.sync.push}), |
28 | 29 | page |
app/page/blogIndex.js | ||
---|---|---|
@@ -18,12 +18,12 @@ | ||
18 | 18 | 'unread.sync.isUnread': 'first' |
19 | 19 | }) |
20 | 20 | |
21 | 21 | exports.create = (api) => { |
22 | - // var contentHtmlObs // TODO get a better cache than this | |
22 | + var contentHtmlObs | |
23 | 23 | |
24 | 24 | return nest('app.page.blogIndex', function (location) { |
25 | - // location here can expected to be: { page: 'blogIndex'} | |
25 | + // location here can expected to be: { page: 'blogIndex'} or { page: 'home' } | |
26 | 26 | // |
27 | 27 | var strings = api.translations.sync.strings() |
28 | 28 | var blogs = blogsEl() |
29 | 29 | |
@@ -37,29 +37,37 @@ | ||
37 | 37 | ]) |
38 | 38 | }) |
39 | 39 | |
40 | 40 | function blogsEl () { |
41 | + if (contentHtmlObs) return contentHtmlObs | |
41 | 42 | // TODO - replace with actual blogs |
42 | 43 | var morePlease = false |
44 | + | |
43 | 45 | var threadsObs = api.state.obs.threads() |
46 | + // var timestamp = new Date() | |
47 | + // threadsObs(ev => console.log(timestamp, ev)) | |
44 | 48 | |
49 | + var threadsObsDebounced = threadsObs // TODO rename or fix debounce | |
50 | + | |
45 | 51 | // DUCT TAPE: debounce the observable so it doesn't |
46 | 52 | // update the dom more than 1/second |
47 | - threadsObs(function () { | |
48 | - if(morePlease) threadsObs.more() | |
49 | - }) | |
50 | - threadsObsDebounced = Debounce(threadsObs, 1000) | |
51 | - threadsObsDebounced(function () { | |
52 | - morePlease = false | |
53 | - }) | |
54 | - threadsObsDebounced.more = function () { | |
55 | - morePlease = true | |
56 | - requestIdleCallback(threadsObs.more) | |
57 | - } | |
53 | + // threadsObs(function () { | |
54 | + // console.log('blogs - update?', morePlease) | |
55 | + // if(morePlease) threadsObs.more() | |
56 | + // }) | |
57 | + // threadsObsDebounced = Debounce(threadsObs, 1000) | |
58 | + // threadsObsDebounced(function () { | |
59 | + // console.log('blogs - set morePlease: false') | |
60 | + // morePlease = false | |
61 | + // }) | |
62 | + // threadsObsDebounced.more = function () { | |
63 | + // console.log('blogs - set morePlease: true', 'requestIdleCallback') | |
64 | + // morePlease = true | |
65 | + // requestIdleCallback(threadsObs.more) | |
66 | + // } | |
58 | 67 | |
59 | 68 | var updates = h('div.blogs', []) |
60 | - // contentHtmlObs = More( | |
61 | - var contentHtmlObs = More( | |
69 | + contentHtmlObs = More( | |
62 | 70 | threadsObsDebounced, |
63 | 71 | function render (threads) { |
64 | 72 | |
65 | 73 | function latestUpdate(thread) { |
Built with git-ssb-web