- From: Trevor N. Suarez <notifications@github.com>
- Date: Thu, 24 Apr 2025 15:38:06 -0700
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/ServiceWorker/issues/1515/2829010469@github.com>
Rican7 left a comment (w3c/ServiceWorker#1515) > I'm not sure we explicitly considered the case of navigating a SPA. Hmm, this is really surprising. I know that Service Workers aren't the newest thing, but I'm definitely surprised that there's no way to track a SPA's current URL without doing messaging back and forth and manually tracking. > You can achieve what you want by first finding windows that match the correct origin/path without fragment and then using postMessage() to ask them their current URL. > > We may want to expose a `client.currentURL` or something. [@jakearchibald](https://github.com/jakearchibald) WDYT? But you can't synchronously wait for a message from the Service Worker, right? So you'd have to somehow post the message from the SW to the page, asking it the URL, and then have the page post a message back, and then have the service worker listen for that message in a different handler? So the logical flow wouldn't be able to be linear at all. I was hoping to do a quick quick to answer the question: "should I show this notification?" by checking to see if the user was already on a page that was showing them the updated information or not, but that doesn't look possible in a simple `push` sw event handler. -- Reply to this email directly or view it on GitHub: https://github.com/w3c/ServiceWorker/issues/1515#issuecomment-2829010469 You are receiving this because you are subscribed to this thread. Message ID: <w3c/ServiceWorker/issues/1515/2829010469@github.com>
Received on Thursday, 24 April 2025 22:38:10 UTC