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. */
What problem are you trying to solve?
Manual cleanup is easy to forget.
try/finallyrequires nesting. Cleanup withusingis more convenient.What solutions exist today?
How would you solve it?