Skip to content
Discussion options

You must be logged in to vote

for your option 2

// untested pseudocode in C#
public JsValue HandleNativeCall(string name, JsValue thisObject, JsValue[] arguments)
{
  // TODO: real call
  return JsValue.Null;
}

public Func<JsValue, JsValue[], JsValue> WrapHandler(string name)
{
  // return a Func that calls HandleNativeCall with the function name
  return (thisObject, arguments) => HandleNativeCall(name, thisObject, arguments);
}

engine.SetValue("hello", WrapHandler("hello"));
engine.SetValue("world", WrapHandler("world"));

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@faljse
Comment options

@lahma
Comment options

lahma Apr 19, 2023
Collaborator

@Genteure
Comment options

Answer selected by faljse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants