How Comlink works: RPC over postMessage
mainComlink is a tiny (1.1kB) RPC (Remote Procedure Call) implementation for the Web Workers postMessage API. It uses ES6 Proxies to remove the mental barrier of manual messaging. Instead of sending and receiving messages, you can interact with values in a different thread as if they were local.
Key Mental Model:
When you use a proxy returned by Comlink.wrap(), all property access and function invocations are inherently asynchronous. As a rule of thumb: If you are using the proxy, put await in front of it.