-
Notifications
You must be signed in to change notification settings - Fork 123
Open
Description
I see this functionality mentioned in the readme, and in a couple of issues, notably #152 , but I can't seem to make it work.
My situation, simplified, is as below. I happen to be using the async variant, in case that has something to do with my inability to share across contexts.
async main() {
const runtime = module.newRuntime();
const context1 = runtime.newContext();
await context1.evalCodeAsync(`
function add(x) {
return x + 50;
};
`);
const test1Res = context.unwrapResult(await context1.evalCodeAsync(`add(50)`));
console.log('add result1 (should be 100):', context1.getNumber(test1Res));
test1Res.dispose();
const contextPointer = context1.ctx.value;
const context2 = runtime.newContext({contextPointer});
// Throws with 'add' is not defined.
const test2Res = context2.unwrapResult(await context2.evalCodeAsync(`add(10)`));
console.log('add result2 (should be 60):', context2.getNumber(test2Res));
test2Res.dispose();
}Any help would be greatly appreciated.
Metadata
Metadata
Assignees
Labels
No labels