absurd-sql icon indicating copy to clipboard operation
absurd-sql copied to clipboard

Multiple Windows (Safari and WKWebView)

Open holtwick opened this issue 3 years ago • 2 comments

First congratulations to your genius approach. It looks promising to solve many issues I face in my projects. Thanks for sharing this solution!

In particular for Safari and WKWebView I wonder if you have an idea how to have multiple windows open and still keep the data in sync. AFAIK there are not shared workers or other contexts except IndexedDB. This results in a similar situation as if one would open a SQLite database natively on different computers on a shared folder.

The only solution I see by now is to have a SQLite database per window and close it, once a window becomes inactive and reopen it, once the window becomes active.

Do you know about a better solution?

holtwick avatar Aug 19 '21 20:08 holtwick

I am going to try to use https://github.com/pubkey/broadcast-channel to solve this issue.

It has a LeaderElection mechanism, ensuring that only one worker will be running. Then I will post messages from the other tabs to the channel, and the leader tab will communicate with the web worker. I am not sure what performance will be, but I hope it will work well 🤔

quolpr avatar Aug 20 '21 07:08 quolpr

Thanks, this looks like a great library to bypass Safari limitations for shared states. I'm looking forward to seeing your results!

holtwick avatar Aug 20 '21 09:08 holtwick