UoaWDCC / uasc-web

Project with the University of Auckland Snowsports Club Website & Booking System. Established in 2023.
https://uasc.co.nz
6 stars 2 forks source link

[FRONTEND] Write custom hook to recieve SSE (Server Sent Events) #778

Closed bcho892 closed 3 weeks ago

bcho892 commented 1 month ago

Is your feature request related to a problem? Please describe.

Because of the new endpoint created in #662 we will now need to have a way to consume the events on the frontend. For our project this will consist of two steps:

  1. Create a generic hook that allows creation of an EventSource for a given endpoint and appropriately attach callbacks or if a request body is required a library such as fetchEventSource would be required
  2. Use that implementation to create a hook that allows us to constantly stream event signup numbers on the front end

[!NOTE] You should not be hard-coding the base url for the endpoint, instead look into process.env to get the appropriate base URL

[!WARNING] There should be a way for us to close the connection if needed

BEFORE MERGING

jeffplays2005 commented 3 weeks ago

Not planned