Developing a basic npm package with signalr integration has been my recent project. Here's how it works:
- First, the user installs the package
- Then, the package establishes a connection using signalr
- At a certain point, the server triggers a function and transmits data through it
- The user needs to be able to “listen” and await this incoming data
Here's what I envision the user doing:
myPackage.on(“dataInTheHouse”, (data) => {
const myData = data;
});
Something along those lines...
I attempted to use an npm package called “event-emitter” for this purpose, but struggled to create a dynamic function for all events and ended up feeling overwhelmed.
How can I overcome this challenge and achieve the desired functionality?