- From: Adam Rice <notifications@github.com>
- Date: Fri, 08 Nov 2024 06:16:27 -0800
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Friday, 8 November 2024 14:16:31 UTC
These days I'm leaning towards providing no parameters to `finally()`, to match the way it works in JavaScript and Promise.prototype.finally. It means that if your stream owns a resource that can only be disposed of once, you'll have to track that yourself in your source/sink implementation, but I suspect people would prefer to do that for robustness anyway. I mean something like ```js const source = { start() { this._need_dispose = true; this._resource = AcquireResource(); }, cancel() { DisposeResource(this._resource); this._need_dispose = false; }, finally() { if (this._need_dispose) { DisposeResource(this._resource); } } ``` This is not actually a good example because you could just always leave the disposal until `finally()` is called. Anyway, if `finally()` takes no arguments we can spec and implement it quickly* and finally close this hole in the spec. *Subject to writing many, many, many wpts. -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/streams/issues/636#issuecomment-2464874645 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/streams/issues/636/2464874645@github.com>
Received on Friday, 8 November 2024 14:16:31 UTC