jailed icon indicating copy to clipboard operation
jailed copied to clipboard

Exposing values from the app to the jailed worker.

Open nahumzs opened this issue 5 years ago • 1 comments

do you know if it's possible to expose values or methods to the jailed plugin?

From what I'm understanding you can expose functions that the worker can execute 1 time and then pass information from the worker/plugin to the application.

I would like to do the opposite let the worker call a function to the application and the application returns a value or method that can be used on the code on the plugin side.

something like:

const api = {
   someFancyStuff: async () => {
     const response = await fetch(url, options);
     return response
  },
  output: () => {
    // do somehting with the ouput
}
}

new jailed.DynamicPlugin(code, api);

so far if I execute application.remote.someFancyStuff() the return value is undefined even if I'm just doing return 1

thank you.

nahumzs avatar Dec 12 '19 06:12 nahumzs

You must use callbacks to communicate asynchronously. Return values are ignored in functions.

willstott101 avatar Feb 25 '20 14:02 willstott101