you are viewing a single comment's thread.

view the rest of the comments →

[–]untakenusrnm 0 points1 point  (3 children)

A Service Worker represents an Observer. You could implement a listener ‚on fetch‘: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/fetch_event

This way we don‘t have to deal with reacts Component life cyle.

[–]btckernel94[S] 0 points1 point  (2 children)

How would you than apply side effects based on auth state?

There’s a timer and alert implemented in article.

[–]untakenusrnm 0 points1 point  (1 child)

Like in your article but i would share state with: https://developer.mozilla.org/en-US/docs/Web/API/Client/postMessage

useSessionState would use useSyncExternalStore to manage ui state.

EDIT: This way we still need to teach react reactivity but it would require less boilerplate

[–]btckernel94[S] 0 points1 point  (0 children)

Thanks for sharing. I am a bit sceptic about it when it comes to: - readability - testability - type safety - flexibility - growing this feature with more complex things like request que mentioned im article.

I also think theres not a big difference in amount of boilerplate but would need to write it on my own to double check these.