Version: 1.2.0
Web Workers
Web Workers are a simple means for web content to run scripts in background threads. The worker thread can perform tasks without interfering with the user interface. MDN
K2 treats web workers as first-class citizens, you can enable it by giving useWorker: true
to any component and it'll transform your data in a separate thread. We're running a separate instance of web-worker per component.
Usage
Limitations
To support web workers we are using useWorker hook by alewin and there are some limitations for using this hook:
- The web worker doesn't have access to the
document
andwindow
object mapData
must be a pure function without any local dependencies as it gets serialized when using it in a web worker.mapData
cannot return a function because the response gets serialized.mapDataParams
cannot contain any function.