fs
fs copied to clipboard
`FileSystemObserver` should support `Symbol.dispose`
What problem are you trying to solve?
Manual cleanup is easy to forget. try/finally requires nesting. Cleanup with using is more convenient.
What solutions exist today?
const obs = new FileSystemObserver(myCallback)
await obs.observe(handle)
try {/* Various activities. */}
finally {obs.disconnect()}
How would you solve it?
// This should be built-in.
const pro = FileSystemObserver.prototype
if (!pro[Symbol.dispose]) {
const desc = Object.getOwnPropertyDescriptor(pro, `disconnect`)
Object.defineProperty(pro, Symbol.dispose, desc)
}
using obs = new FileSystemObserver(myCallback)
await obs.observe(handle)
/* Various activities. */
Blocked on https://github.com/whatwg/webidl/pull/1488 ?