How to bind events to custom backend service?

I am trying to create a custom USB service using node-usb that fires an event whenever a device connects. The service works fine when I create a function to get a list of connected devices, but I get an error when I try to listen to node-usb’s attach event.

ERROR TypeError: Cannot read property 'apply' of undefined
    at [...]/node_modules/@theia/core/lib/common/event.js:176:33

It looks like my callback does not get passed correctly to the Event. Is my binding wrong? Any ideas?

Here is my code: https://pastebin.com/0xjJnfXD

I could take a look if you could set up a public repo I can clone and build. It is hard to figure out what is causing the TypeError: Cannot read property 'apply' of undefined error from the pastebin snippet.

Ah yeah, that should be much more convenient in many ways. I have set up a stripped down version here: https://github.com/KR155E/theia-test

Build and launch it with yarn all.

1 Like

Forgot to mention: connect any USB device while Theia is running to see the error in the console.