Skip to content

ExportFunction help #1750

Closed Answered by Hadaward
Hadaward asked this question in Q&A
Discussion options

You must be logged in to vote

Sorry, i just figured out how to do this:

public class Example
{
  public Example(Engine engine) {
    engine.Modules.Add("@example", builder => {
      builder.ExportFunction("log", new Func<JsValue[], JsValue>(args => Log(args)))
    });
  }
  
  public JsValue Log(JsValue[] args)
  {
      string message = string.Join("\t", args.Select(arg => arg.AsString()).ToArray());
      Console.WriteLine(message);
  
      return JsValue.Undefined;
  }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Hadaward
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant