0

Is there a way to wait till the receiving party processes message sent using port.postMessage(message)? I'd expect something like callback passed as second argument similarly to chrome.scripting.executeScript(injection, callback)

czerny
  • 15,090
  • 14
  • 68
  • 96

1 Answers1

1

To my knowledge not natively but a wrapper is easy to implement. You need a class that will generate a random UID (Unique ID) for each message and store a map { [uid]: cb }. Attach generated UID to the message. Response will also need to contain same UID.

QuentinCaffeino
  • 198
  • 3
  • 14