Improve the interoperability with js

Currently, moonbit can call simple functions from js side with ffi, this ability is not enough in some complex situtations.
Eg. There is a function takes a parameter which has Function type, it can not be called from moonbit side for now.

// test.js
 *  @param {() => void} hook
export function onFlush(hook) {

Hi, thank you for your feedback. Currently, the FFI of MoonBit is still somewhat limited. We acknowledge that there is a need for calling MoonBit functions in JavaScript, but for now it seems to be a non-trivial effort and probably won’t be in our top priorities.

However, if you are passing a JavaScript hook into MoonBit for use with onFlush, then my suggestion would be to define a type HookFunction so that you can pass the function around in MoonBit.

1 Like