jailed
jailed copied to clipboard
Exposing values from the app to the jailed worker.
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.
You must use callbacks to communicate asynchronously. Return values are ignored in functions.