Nick
Nick
DDeno
Created by Nick on 12/3/2023 in #help
Return lazy struct fields from Op
My goal is to build a plugin system which allows invoking user defined code. One of the features I am looking to support is the ability to invoke user provided functions with function parameters, an example:
// Ideally, I can model this in an Op:
type Input = {
lazyValueA: () => Promise<number>;
lazyValueB: () => Promise<number>;
}

// Example usage
const userCallback: (input: Input) => Promise<number> = async ({lazyValueA, lazyValueB}) => {
return (await lazyValueA()) + (await lazyValueB());
}
// Ideally, I can model this in an Op:
type Input = {
lazyValueA: () => Promise<number>;
lazyValueB: () => Promise<number>;
}

// Example usage
const userCallback: (input: Input) => Promise<number> = async ({lazyValueA, lazyValueB}) => {
return (await lazyValueA()) + (await lazyValueB());
}
I have explored these paths but neither have been successful: - model the Op return as an Input struct with v8::Function fields (while returning v8::Function values is supported) - model the Op return as an Input as Future values, but serializing Future is obviously problematic Reading through the deno_ops and v8_serde packages, I don't see an obvious way to accomplish this (very open to thoughts about how to restructure this, feels like im working against the tooling here)
4 replies