feat:auto clear timer while context is released

This commit is contained in:
pengfei.zhou 2019-11-19 10:38:00 +08:00
parent 66da6eb13a
commit 9a25e14dc9

View File

@ -193,6 +193,18 @@ export function jsObtainContext(id: string) {
} }
export function jsReleaseContext(id: string) { export function jsReleaseContext(id: string) {
const context = gContexts.get(id)
if (context) {
timerInfos.forEach((v, k) => {
if (v.context === context) {
if (global.nativeClearTimer === undefined) {
return Reflect.apply(_clearTimeout, undefined, arguments)
}
timerInfos.delete(k)
nativeClearTimer(k)
}
})
}
gContexts.delete(id) gContexts.delete(id)
} }