Separate event type on server side
This commit is contained in:
parent
2977247193
commit
ddc73ad30c
@ -57,7 +57,8 @@ async function run() {
|
|||||||
const stringFormat = JSON.stringify(document);
|
const stringFormat = JSON.stringify(document);
|
||||||
eventArray = [stringFormat, ...eventArray];
|
eventArray = [stringFormat, ...eventArray];
|
||||||
})
|
})
|
||||||
response.write(`event: events, data: [${[...eventArray]}]\n\n`)
|
response.write(`event: events \n`)
|
||||||
|
response.write(`data: [${[...eventArray]}]\n\n`)
|
||||||
|
|
||||||
changeStream.on("change", data => {
|
changeStream.on("change", data => {
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import { useSSE, SSEProvider, createCustomSource } from 'react-hooks-sse';
|
|||||||
import './App.css';
|
import './App.css';
|
||||||
import EventList from '../eventList/EventList.js';
|
import EventList from '../eventList/EventList.js';
|
||||||
|
|
||||||
function SSE() {
|
const SSE = () => {
|
||||||
const state = useSSE('events');
|
const state = useSSE('events');
|
||||||
const [events, setEvents] = useState([]); // initialises Event state
|
const [events, setEvents] = useState([]); // initialises Event state
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user