Inter plugin communication: Return a value upon invoking a command

I have two UXP plugins, running in InDesign, and I’m able to invoke a command from plugin A to B.
I would like plugin B to return a value.
When logging the results of the call, I can confirm that the command invoked runs, but I get the following:

console.log(await plugin.invokeCommand('simpleCommand'))

>> {success: true, resultData: null}

The command is configured as follows:

entrypoints.setup({
	commands: {
		simpleCommand: () => {		// tried making this async
			// tried return { resultData: 'bonjour!'}
			return 'bonjour!'
		},
	},
})

How can I make plugin B return a value to plugin A after executing the command?

Thanks!

Well, the docs do say that the return value is a Promise of void, so any return value would be ignored. In fact I don’t even know if you can safely rely upon the behavior that the command actually finished when the promise is fulfilled, might be that the request is just put onto a message queue and the Promise is fulfilled for the the caller already at that point. The behavior is not really documented from what I’ve seen.

Safest bet would be to simply call back plugin A from plugin B when plugin B has completed I suppose?

Thanks for your input :slight_smile:
That’s the approach we used so far, but there are times where it would be very convenient to have a plugin invoke a command, and be able to await for something to have happened, and to get a response, before executing some more code.

So here goes to hoping that someone knows about a way to achieve this without such workaround :slight_smile: