JSObject constructor

JSObject(
  1. String refOrClazz, [
  2. List? arguments
])

Implementation

JSObject(String refOrClazz, [List? arguments]) {
  if (refOrClazz.contains("ref:")) {
    this.objectRef = refOrClazz;
  } else {
    final valueORObjectRef = DevMPJSHost.shared.newObject(
      refOrClazz,
      arguments?.map((e) => transformToBrowserJSObject(e)).toList() ?? [],
    );
    if (valueORObjectRef is Map && valueORObjectRef["clazz"] == "object") {
      this.objectRef = valueORObjectRef["ref"];
    } else {
      throw Error.safeToString("Fail to create $refOrClazz object");
    }
  }
}