execute method

void execute({
  1. required OnObserverCall observerCall,
  2. OnAccessCall? accessCall,
  3. OnFinishedCall? finishedCall,
  4. Map<String, dynamic>? params,
})

创建isolate线程并回调结果信息 observerCall 订阅线程中函数 finishedCall 结束后返回回调数据

Implementation

void execute({
  required OnObserverCall observerCall,
  OnAccessCall? accessCall,
  OnFinishedCall? finishedCall,
  Map<String, dynamic>? params,
}) async {
  ReceivePort receivePort = ReceivePort();
  await Isolate.spawn(_observer, receivePort.sendPort);
  SendPort sendPort = await receivePort.first;
  var receive = await _sendReceive(sendPort, params ?? {}, observerCall, accessCall);
  if (finishedCall != null) {
    finishedCall(receive);
  }
  Logger.instance.info(receive);
}