Re: [w3c/ServiceWorker] Provide a way to attach data to clients (#1475)

I would advice against replicating the pattern of a global state that the History API opted for.

That state management in a way unfortunately mimics the global state that event listeners had before addEventListener() was introduced, where whenever you eg. added a new onclick event, you needed to ensure that you saved and wrapped any existing one, or else you would accidentally remove it.

If eg. a library decides that it fully owns the state management and itself never reads what anyone else has written there but rather plainly writes whatever it thinks the state should be from its perspective, then it can make it very hard for others to do anything powerful with it if that library becomes widely spread.

I eg. had en encounter with that many years ago with GitHub’s Pjax library: https://github.com/defunkt/jquery-pjax/pull/79/files#diff-256b2e7d3ffe31142c00fa086e15d3a6R128 It decided that it was the one and only true source of History API state, making it hard for other History API users to persist its state along side it, forcing me to fork the library for it to work and since I ultimately failed to upstream my patch I became forced to continue to use my fork for that site.

I’m not looking forward to relive such an experience with a new API if that can be avoided.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1475#issuecomment-539208871

Received on Monday, 7 October 2019 21:19:25 UTC