MessagePortRequestX extension

Type-safe Web Worker communication with MessageChannel integration.

Essential for background processing in web applications using Web Workers while maintaining type safety and structured error handling. Integrates seamlessly with JavaScript's MessageChannel API.

on
  • MessagePort

Methods

request<R>(String command, {Map<String, Object?>? data, Duration timeout = const Duration(seconds: 3)}) Future<R>

Available on MessagePort, provided by the MessagePortRequestX extension

Send a typed request to Web Worker and await the response.
sendCmd(String command, {Map<String, Object?>? data, JSObject? transfer}) → void

Available on MessagePort, provided by the MessagePortRequestX extension

Send a structured command to the Web Worker.