4 ms·
One alternative to Comlink is to use IndexedDB transactions and polling. IndexedDB can be shared amongst Web Workers for the same origin (localStorage cannot).
by emadda 3y ago
One alternative to Comlink is to use IndexedDB transactions and polling.
IndexedDB can be shared amongst Web Workers for the same origin (localStorage cannot).
https://dexie.org https://dexie.org is a nice IndexedDB library.
As an example, if you have many web workers, each can write their current state or use transactions to take items from a queue, and a central UI can just query the single IndexedDB.
- moritzwarhier 3y agoWow, I had no idea about this! What do you think is the current state of adoption for IndexedDB apart from fingerprinting?
- emadda 3y agoI'm not sure to be honest, https://caniuse.com/indexeddb https://caniuse.com/indexeddb lists >95% for browser implementations. I quite like IndexedDB as it is widely supported by browsers. Although for simple data I prefer the sync localStorage API.
- moritzwarhier 3y agoIt's the same for me! sessionStorage is handy as well for things like autocomplete result caching. Was wondering about adoption in usage, not implementation.
- franky47 3y agoI use both Comlink and Dexie, for different purposes. Comlink gives a seamless abstraction over the worker "bridge", and Dexie does the same for the complex IDB API. I have run into performance issues with Dexie when querying lots of objects (~1M) from a collection, but it looks like it's more of a limitation on IndexedDB itself.