Class NativeFunction


  • @JsType(isNative=true,
            name="Function",
            namespace="<global>")
    public class NativeFunction
    extends Object
    JsInterop wrapper for interacting with the JavaScript Function type.
    Since:
    1.0
    Author:
    Vaadin Ltd
    • Constructor Detail

      • NativeFunction

        public NativeFunction​(String... paramsAndCode)
        Creates a new function with the given parameters and implementation.
        Parameters:
        paramsAndCode - parameter names followed by the code of the function
    • Method Detail

      • apply

        public Object apply​(Object thisArg,
                            JsArray<?> arguments)
        Invokes this function with a given this and arguments provided as an array.
        Parameters:
        thisArg - the value of this
        arguments - an array of arguments
        Returns:
        the return value of the invocation
      • call

        public Object call​(Object thisArg,
                           Object... arguments)
        Invokes this function with a given this and arguments provides as varargs.
        Parameters:
        thisArg - the value of this
        arguments - the arguments to invoke this function with
        Returns:
        the return value of the invocation
      • create

        @JsOverlay
        public static <T> T create​(String... paramsAndCode)
        Creates a new function with the given parameters and implementation. The return value of this method is intended to be used as a type annotated with @JsFunction.
        Type Parameters:
        T - the function type
        Parameters:
        paramsAndCode - parameter names followed by the code of the function
        Returns:
        the native function