mirror of
https://github.com/urbit/shrub.git
synced 2025-01-05 19:46:50 +03:00
better async wasp handling
The "depends last" refactor had broken partial page reloading
This commit is contained in:
parent
1fd71203ad
commit
cae52a68cd
17
mar/urb.hoon
17
mar/urb.hoon
@ -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))})
|
||||
; }
|
||||
==
|
||||
==
|
||||
|
@ -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')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user