How to reference/call a Godot function from JavaScript?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Dlean Jeans

I’m implementing an API which has abstract callback function to be overriden

JavaScript.eval('''
    api.onConnect = function(device_id) {
        // check device
    };''')

Is there anyway other way to pass in a Godot function

func _ready():
    JavaScript.eval('api.onConnect = %s' % 'emitOnConnect'); # I dunno

function emitOnConnect(device_id):
    emit_signal('on_connect', device_id)

without polling with _process or _physics_process?