Closed andrey-skl closed 8 years ago
Hello Andrey, thanks for your suggestion. This will not be implemented, because Promises is just a syntacsic sugar over the callbacks - you still provide a callback to the Promise constructor which as result makes the code more complex without a reason.
It is technically possible to handle the returned value of an exported method and send the result over a message, but since messages are handled asynchronously, it is only possible to handle the result in some sort of callback on the oppsite side (no matter if this is an ordinary callback, or sugared with a Promise pattern). Therefore in order to keep the code simplier and consistent, returned value is ignored, and callbacks are suggested to be used instead. This make the exported function behave in the way as if it would be used directly.
Also I don't like Promises ;-)
@asvd Okay and thank you for the honest reply.
Communication with child process is built on top of postMessage now, and that's why it doesn't support returning value. And we have to use that old-style callbacks to return value from function.
It would be much better to wrap that functions into promises to allow returning values as well as promises and all such things.
Example of current plugin code:
What it could look like:
And then you can call plugin code from your App so easy: