- From: Jackie(Guokai) Han <notifications@github.com>
- Date: Mon, 08 Jan 2024 06:57:52 -0800
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/ServiceWorker/issues/1698/1881172251@github.com>
To understand this proposal, we must first understand the current way of working. The current way of working: 1. Developers register event handlers at top level (i.e. the first event loop) in service worker. And the browser remembers what event types this service worker want to handle. (When service worker is terminated, the browser still remembers what event types this service worker want to handle). 2. when new events are fired, browser wakes up service worker if it is not active. 3. after the first event loop of service worker, browser dispatch events to event handlers that are registered in the first event loop. This proposal is 1. Developers can register event handlers for service worker at anywhere and anytime: including first event loop and later(e.g. in a function that runs later) in service worker, and even can be registered at outside of service worker at anytime (e.g in other extension pages). 2. Here you will ask if event handers are not registered at top level, where does the browser find them after the first event loop of service worker? 3. Here is the key point. When `subscribe()` an event, in addition to remember the event type, the browser also needs to remember the function name, so that the brwoser can find them. Anyway, in order to be able to dynamically add or remove, enable or disable event handlers, the browser must remember some additional information beyond service worker lifecycle. -- Reply to this email directly or view it on GitHub: https://github.com/w3c/ServiceWorker/issues/1698#issuecomment-1881172251 You are receiving this because you are subscribed to this thread. Message ID: <w3c/ServiceWorker/issues/1698/1881172251@github.com>
Received on Monday, 8 January 2024 14:57:59 UTC