Add LNVue.onidle(cb,thisptr)
parent
8aae175692
commit
75924bc19a
11
demo.html
11
demo.html
|
@ -48,8 +48,11 @@
|
|||
LNVue.addRoute("/controls","/controls.html");
|
||||
LNVue.addRoute("/table","/table.html");
|
||||
|
||||
let message = { value: "" };
|
||||
|
||||
app = new LNVue("#frame",{
|
||||
data: {
|
||||
message: message,
|
||||
columns: {
|
||||
FirstName: {
|
||||
label: 'Vorname',
|
||||
|
@ -123,6 +126,14 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
LNVue.onidle(()=>{
|
||||
message.value = "idle time reached. Message written.";
|
||||
setTimeout(()=>{
|
||||
message.value = "fired from the idle job: new message after 1000ms.";
|
||||
},1000);
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
|
|
@ -47,6 +47,28 @@
|
|||
|
||||
}
|
||||
|
||||
LNVue.$idles = [];
|
||||
LNVue.onidle = function(cb,thisval = null){
|
||||
let scheduled = LNVue.$idles.length > 0;
|
||||
let n=0;
|
||||
|
||||
for (;n<LNVue.$idles.length;n++){
|
||||
let idle = LNVue.$idles[n];
|
||||
if ((idle[0] == cb) && (idle[1] == thisval))
|
||||
break;
|
||||
}
|
||||
if (n == LNVue.$idles.length)
|
||||
LNVue.$idles.push([cb,thisval]);
|
||||
|
||||
if (!scheduled)
|
||||
setTimeout(()=>{
|
||||
while (LNVue.$idles.length > 0){
|
||||
let idle = LNVue.$idles.pop();
|
||||
idle[0].call(idle[1]);
|
||||
}
|
||||
},0);
|
||||
}
|
||||
|
||||
LNVue.$ = function(src){
|
||||
let el = document.createElement("parse");
|
||||
el.innerHTML = src;
|
||||
|
|
Loading…
Reference in New Issue