- From: Peter Reitinger <notifications@github.com>
- Date: Tue, 20 May 2025 21:59:08 -0700
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/ServiceWorker/pull/1771/c2896578575@github.com>
preitinger left a comment (w3c/ServiceWorker#1771) > Will you elaborate more on why you think `void` is correct? It became `ServiceWorkerRegistration` in #1767. The change is based on the discussion in #1472. Chromium, Mozilla, and WebKit agreed to use this. First of all, I noticed that the typescript signature of `ServiceWorkerRegistration.update()` told me that it returns `Promise<void>`. Originally, I created an issue in the MDN web docs which I use for my daily work. There, they told me that this spec says that `ServiceWorkerRegistration.update()` should return `Promise<ServiceWorkerRegistration>`. Now, considering the lifecycle of `ServiceWorkerRegistration`, I wonder what it should return, actually. (The detail description for update() says btw nothing about the return value, just that an activity is started and when it is done the promise returns. Not that with a value. Only in fail cases it describes which exception is thrown. And for me, just as an interested newbie user (switched to typescript 2 years ago) and not used to this specification process, it seems to be very logical that `update()` just fulfills its `Promise<void>` when the `update` is done. And then, the user knows that he will find the new service worker in `ServiceWorkerRegistration.installing` (or if some strange super-quick happens) already in `ServiceWorkerRegistration.waiting` of the `ServiceWorkerRegistration` object which he owns anyway because he called `update()` on it. In my opinion, if `update` should return a value at all except for the fact that it has completed which means `void`, then not an object of `ServiceWorkerRegistration`, but a `ServiceWorker` which must then be probably the same as referenced by `ServiceWorkerRegistration.installing` (or if that is possible at all that the installation is so fast) in `ServiceWorkerRegistration.waiting`. It makes no sense at all imo to return a `ServiceWorkerRegistration` except for itself for some function chaining or the like. -- Reply to this email directly or view it on GitHub: https://github.com/w3c/ServiceWorker/pull/1771#issuecomment-2896578575 You are receiving this because you are subscribed to this thread. Message ID: <w3c/ServiceWorker/pull/1771/c2896578575@github.com>
Received on Wednesday, 21 May 2025 04:59:13 UTC