Kotlin Multiplatform interface implementation in JavaScript?

Suppose I have a Kotlin Multiplatform project with a method, which takes an interface as an argument like this.

interface MyInterface {
    operator fun invoke()
}

class MyClass {
    fun execute(client: MyInterface) {
        client()
    }
}

In Java I could just call the execute() method like this:

    void test() {
        MyClass myClass = new MyClass();
        myClass.execute(() -> {
            //Do stuff
        });
    }

Now in my Multiplatform project I have generated the JS file, but how do I call it in JavaScript, since JS doesn’t have interfaces? I am trying to do this in Node.js.

Generated JS code for execute function is:

  MyClass.prototype.execute = function (client) {
    client.invoke();
  };

So you have to pass any object which has invoke method.

    var myClass = new ModuleName.package.name.MyClass();
    var b = {
        invoke: function() {
            console.log("Hi")
        }
    };

    myClass.execute(b)

NB: I added @JsName("execute") annotation to execute function to avoid name mangling.

Thanks!