JSObject.makeFunctionWithCallback constructor
JSObject.makeFunctionWithCallback(
- JSContext context,
- String name,
- Pointer<
NativeFunction< ? callAsFunctionJSObjectCallAsFunctionCallback> >
Convenience method for creating a JavaScript function with a given callback as its implementation.
name
A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function.
callAsFunction
The JSObjectCallAsFunctionCallback to invoke when the function is called.
Implementation
JSObject.makeFunctionWithCallback(
this.context,
String name,
Pointer<NativeFunction<JSObjectRef.JSObjectCallAsFunctionCallback>>?
callAsFunction)
: this.pointer = JSObjectRef.jSObjectMakeFunctionWithCallback(
context.pointer,
JSString.fromString(name).pointer,
callAsFunction ?? nullptr);