bindExternalFunction method

void bindExternalFunction(
  1. String id,
  2. Function function, {
  3. bool override = true,
})

Register an external function in script there must be a declaraction also in script for using this the function here can be either a pure dart function or a HTExternalFunction we use a conventions to distinguish different types of functions here:

  1. for toplevel external functions, use id like '$functionId'
  2. for static method or contructor of a class, use id like '$classId.$functionId'
  3. for external functions within a explicity declared namespace, use id like '$namespaceId::$functionId'

Implementation

void bindExternalFunction(String id, Function function,
    {bool override = true}) {
  if (externalFunctions.containsKey(id) && !override) {
    throw HTError.defined(id, HTErrorType.runtimeError);
  }
  externalFunctions[id] = function;
}