Skip to content

useSocketEvent with callback? #38

@niekvenlo

Description

@niekvenlo

It looks like it would be fairly simple to add callback support to the useSocketEvent hook.
The API would then support something like this:

useSocketEvent('name-of-event', (response) => handleResponse(response));

It could be as simple as adding this effect:

useEffect(() => callback(lastMessage), [lastMessage]);

(Probably not wise to add callback to deps, because callback will change on every render)

Is there a good reason not to include this functionality?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions