-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose typed EventHandlersDataMap #265
Comments
I've managed to figure out how to get to it in a really long-winded way, but would still prefer the file exposed in the package if possible, this is my solution:
Evaluates as:
|
Agree, I was really confused when this wasn't exposed. |
I've exported all of the EventHandlersData params in a way that is similar to @artdevgame, but I don't think there's a way for me to do dynamic registration of listeners in a manner similar to below protected registerEventTransformers(transformers : V4EventTransformerSet) : void
{
for (const transformer of transformers) {
this.transformerRegistery[transformer.obsEventType] = transformer;
this.websocket.on(transformer.obsEventType, this.notifyListener.bind(this, transformer.obsEventType, transformer));
}
}
protected notifyListener<EventType extends ObsV4EventNames>(obsEventType : EventType, transformer : V4EventTransformer, eventData : ObsV4EventHandlersData[EventType]) : void
{
if (this.callback) {
this.callback(transformer.systemMessageType, transformer.buildSystemMessage(eventData));
}
}
I know y'all are probably full steam ahead on v5, but it is sort of a major roadblock for me. Any help? |
Translators are currently not registering as their event signatures are not being recognized by the obs websocket `.on()` method. See: obs-websocket-community-projects/obs-websocket-js#265
Description:
This could just be that I'm a novice with TypeScript, but I'm using this library in my project and I would like to reference the
EventHandlersDataMap
type. I don't think I can currently do that as the file concerned isn't available in node_modules.I've tried getting hold of the map with this, but it feels hacky/wrong and I'm still unsure how to type an event handler to a specific use-case:
This is how I'm trying to get a specific data map for an event handler:
It looks like obsWebsocket.ts would be a lot easier to do this kind of thing, is that possible?
Versions Used (if applicable):
The text was updated successfully, but these errors were encountered: