listen method

void listen()

Implementation

void listen() async {
  void onMessage(Event event) {
    final msgEvent = event as MessageEvent;
    final data = msgEvent.data as OpenpgpResponse;
    var completer = completers[data.id];
    if (completer == null) {
      return;
    }
    if (data.error != null && data.error! != '') {
      completer.completeError(data.error!);
    } else {
      completer.complete(data.response?.toDart);
    }
    completers.remove(data.id);
  }

  worker.onmessage = onMessage.toJS;
}