Skip to content
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

Is DispatchEvent ts definition wrong ? #65

Open
mgohin opened this issue May 28, 2024 · 3 comments
Open

Is DispatchEvent ts definition wrong ? #65

mgohin opened this issue May 28, 2024 · 3 comments

Comments

@mgohin
Copy link

mgohin commented May 28, 2024

Hi,

In types/sse.d.ts the DispatchEvent is defined as this : export type DispatchEvent = (type: string, listener: Function) => boolean;.

In lib/sse.js the dispatchEvent function only takes the event as argument : this.dispatchEvent = function(e) {.

Is the TS definition wrong ?

Have a great day ;)

@mpetazzoni
Copy link
Owner

@mgohin Yes the types no longer match. If you know more about this area, would you be able to help take a look at #59 and see if that's a change that would work? I'm not sure how to test that kind of thing myself locally.

@mgohin
Copy link
Author

mgohin commented May 29, 2024

You removed the definition of DispatchEvent so yes it'd definitely work, but I guess you could keep definitions, just keep them updated ?

To test it, you can do like me, try to override the default function (this.source is the SSE instance, and my goal here is to intercept all events received) :

image

So here you see that if I don't use // @ts-ignore I got an error because my function does not match the (outdated) definition.

By the way, is there a way to intercept all events without doing like I'm doing ? I cannot subscribe to all events because I don't know all event names :)

@mpetazzoni
Copy link
Owner

Thanks @mgohin.

There is no way to (currently) get all events, see #62 (comment) for the reason why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants