Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing asynchronous delegates into ScriptObject #250

Open
cincuranet opened this issue Aug 6, 2020 · 3 comments
Open

Importing asynchronous delegates into ScriptObject #250

cincuranet opened this issue Aug 6, 2020 · 3 comments

Comments

@cincuranet
Copy link
Contributor

Is there a way to import asynchronous delegates into ScriptObject? Something like:

var scriptObject = new ScriptObject();
scriptObject.Import("foobar", (Func<ScriptObject, Task<string>>)...);

The reason I'm asking is because I have a bunch of functions that do some IO, and I'd like to convert them into asynchronous and hopefully use the RenderAsync in the methods up.

@xoofx
Copy link
Member

xoofx commented Nov 8, 2020

Currently no way. I haven't thought about how to bring such a feature, and PR welcome if you find a way (better on top of branch 3.0)

@gitfool
Copy link

gitfool commented May 28, 2021

I'd also like to have this; in my case for functions in a class deriving from ScriptObject.

@gitfool
Copy link

gitfool commented May 28, 2021

Actually this worked once I switched to RenderAsync:

public sealed class PulumiFunctions : ScriptObject
{
    public static Task<string> Output(Output<string> output) => output.GetValueAsync();
}

...

Output.Create(template.RenderAsync(context).AsTask());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants