Thread constructor

Thread({
  1. required dynamic onMessage(
    1. ThreadResponse
    ),
})

Constructs a Thread with the given onMessage callback.

The constructor generates a unique ID for the thread, initializes the readyState completer, and calls the init method to set up the thread.

Implementation

Thread({
  required this.onMessage,
}) {
  id = generateUniqueId();
  readyState = Completer();
  init();
}