-
Notifications
You must be signed in to change notification settings - Fork 136
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
filter callback function doesn't show the JSON parsed message #205
Comments
@lucafaggianelli Maybe some new options in the options param of Maybe there is a way to use an option, |
Yeah indeed I would add an argument for those not using json |
Here is where the message is being captured in webSocketInstance.onmessage = (message: WebSocketEventMap['message']) => {
heartbeatCb?.();
optionsRef.current.onMessage && optionsRef.current.onMessage(message);
if (typeof optionsRef.current.filter === 'function' && optionsRef.current.filter(message) !== true) {
return;
}
// ...
setLastMessage(message);
}; That This does sort of break the generally-good rule of calculating values that can be derived from other state, instead of maintaining two pieces of state, but that might be justified by optimization. |
hi, I'm using the filter callback to filter messages, though that callback has a
MessageEvent
as argument, so I need toJSON.parse
the message before applying the filter:then later I use the
lastJsonMessage
hook property so I guess I parse the message twice... is there another solution to avoid a double parse?The text was updated successfully, but these errors were encountered: