v1.0.100 useSSESubscription ignore ping
All checks were successful
Deploy / Publish (push) Successful in 19s
All checks were successful
Deploy / Publish (push) Successful in 19s
This commit is contained in:
parent
f812320698
commit
32796e0df2
@ -27,9 +27,13 @@ export function useSSESubscription<T>({ enabled = true, url, onNewData, onDiscon
|
||||
eventSource.addEventListener("close", () => devlog(`EventSource closed with ${url}`));
|
||||
eventSource.addEventListener("message", event => {
|
||||
try {
|
||||
const newData = JSON.parse(event.data) as T;
|
||||
devlog(`new SSE: ${marker}`, newData);
|
||||
onNewDataRef.current([newData]);
|
||||
console.log("EVENT")
|
||||
console.log(event)
|
||||
if (event.data !== '{"event": "ping"}') {
|
||||
const newData = JSON.parse(event.data) as T;
|
||||
devlog(`new SSE: ${marker}`, newData);
|
||||
onNewDataRef.current([newData]);
|
||||
}
|
||||
} catch (error) {
|
||||
devlog(`SSE parsing error: ${marker}`, event.data, error);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@frontend/kitui",
|
||||
"version": "1.0.98",
|
||||
"version": "1.0.99",
|
||||
"description": "test",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.js",
|
||||
|
Loading…
Reference in New Issue
Block a user