Class NativeFunction

java.lang.Object
com.vaadin.client.flow.util.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 Summary

    Constructors
    Constructor
    Description
    NativeFunction(String... paramsAndCode)
    Creates a new function with the given parameters and implementation.
  • Method Summary

    Modifier and Type
    Method
    Description
    apply(Object thisArg, JsArray<?> arguments)
    Invokes this function with a given this and arguments provided as an array.
    call(Object thisArg, Object... arguments)
    Invokes this function with a given this and arguments provides as varargs.
    static <T> T
    create(String... paramsAndCode)
    Creates a new function with the given parameters and implementation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • 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 Details

    • 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