better async wasp handling

The "depends last" refactor had broken partial page reloading
This commit is contained in:
Anton Dyudin 2016-05-12 16:41:46 -07:00
parent 1fd71203ad
commit cae52a68cd
2 changed files with 26 additions and 20 deletions

View File

@ -5,14 +5,6 @@
/= urb-wasp-data-js /: /%/wasp-data /js/
!:
|_ {{dep/@uvH hed/marl} {dep-bod/@uvH bod/marl}}
++ linked-deps-js
'''
urb.waspAll = function(sel){
[].map.call(document.querySelectorAll(sel), urb.waspElem)
}
urb.waspAll('script'); urb.waspAll('link')
'''
++ grow :: convert to
|%
++ mime [/text/html (taco html)] :: convert to %mime
@ -30,11 +22,12 @@
:~ ;script@"/~/on/{<dep>}.js"(urb_injected "", async "", onload "setTimeout(urb.onDep,2000)");
;script(urb_injected "")
;- (trip urb-wasp-data-js)
; window.urb = window.urb || \{}
; urb.waspWait = []
; urb.wasp = urb.wasp || [].push.bind(urb.waspWait)
; urb.onDep = function()\{
; urb.waspDeps();
; urb.waspData({(pojo %s (scot %uv dep-bod))});
;- (trip linked-deps-js)
; urb.waspWait.map(urb.wasp)
; urb.onLoadUrbJS()
; urb.waspData({(pojo %s (scot %uv dep-bod))})
; }
==
==

View File

@ -1,7 +1,11 @@
window.urb = window.urb || {}
urb.waspWait = []
urb.wasp = urb.wasp || [].push.bind(urb.waspWait)
// debugging
urb.verb = false
urb.sources = {}
urb.waspDeps = function(){
urb.deps.map(function(a){urb.sources[a] = "dep"})
}
@ -33,12 +37,21 @@ urb.waspData = function(dep){
urb.datadeps[dep] = true
urb.wasp(dep)
}
urb.ondataupdate = urb.onupdate // overridable
var _onupdate = urb.onupdate
urb.onupdate = function(dep){
if(urb.verb)
console.log("update", urb.datadeps[dep] ? "data" : "full", dep, urb.sources[dep])
if(urb.datadeps[dep]) urb.ondataupdate(dep)
else _onupdate(dep)
urb.onLoadUrbJS = function(){
urb.ondataupdate = urb.ondataupdate || urb.onupdate // overridable
var _onupdate = urb.onupdate
urb.onupdate = function(dep){
if(urb.verb)
console.log("update", urb.datadeps[dep] ? "data" : "full", dep, urb.sources[dep])
if(urb.datadeps[dep]) urb.ondataupdate(dep)
else _onupdate(dep)
}
urb.waspDeps()
urb.waspAll = function(sel){
[].map.call(document.querySelectorAll(sel), urb.waspElem)
}
urb.waspAll('script'); urb.waspAll('link')
}