都上左一段時間呢個post
每次見人講親啲tech野都睇唔明
Symbol.dispose
咩情況下會唔callconst disposableFunc = () => {
console.debug('doing shit')
// do some shit...
return {
[Symbol.dispose]: () => {
console.debug('cleanup shit')
// cleanup some shit...
}
}
}
(async () => {
using _ = disposableFunc()
try {
await someOtherShit()
} catch (e) {
console.debug(e)
}
})()