call method

  1. @override
Future<void> call(
  1. SendPort sendport
)
override

Implementation

@override
Future<void> call(SendPort sendport) async {
  await onInit?.call(initData);
  final ReceivePort receivePort = ReceivePort();
  sendport.send(receivePort.sendPort);
  receivePort.listen((message) {
    if (message is _WorkerExit) {
      receivePort.close();
      return;
    }

    if (message is MessageWithID<I>) {
      final (id, payload) = message;
      entry(payload, (response) {
        sendport.send((id, response));
      });
      return;
    }

    entry(message, sendport.send);
  });
}