mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: ctx.setInterval support
This commit is contained in:
1 parent
6e04a1a8a1
commit
672c553f4c
3 files changed
+14
-11
No files matched your search
@@ -31,9 +31,9 @@ export class Runtime {
|
||||
if (this.loaded) throw new Error(`Module ${this.filename} was already loaded`);
|
||||
this.sideEffect = false;
|
||||
if (typeof module.dispose === 'function') this.disposables.push(module.dispose);
|
||||
const T = (origFunc) => (origFunc ? (...args) => {
|
||||
const T = (origFunc, disposeFunc?) => (origFunc ? (...args) => {
|
||||
const res = origFunc(...args);
|
||||
this.disposables.push(res);
|
||||
this.disposables.push(disposeFunc ? () => disposeFunc(res) : res);
|
||||
return res;
|
||||
} : null);
|
||||
module.apply({
|
||||
@@ -43,6 +43,9 @@ export class Runtime {
|
||||
once: T(bus.once),
|
||||
off: bus.off,
|
||||
addScript: T(addScript),
|
||||
setInterval: T(setInterval, clearInterval),
|
||||
setTimeout: T(setTimeout, clearTimeout),
|
||||
setImmediate: T(setImmediate, clearImmediate),
|
||||
} as Context);
|
||||
if (module.sideEffect) this.sideEffect = true;
|
||||
this.loaded = true;
|
||||
|
||||
Reference in new issue
Block a user