Skip to content

Commit

Permalink
Add some documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kodeFant committed Sep 1, 2023
1 parent f514043 commit c21290e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions IHP/DBEvent.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ respondDbEvent eventName = do
sqlExec createTriggerSql ()
pure ()


pgListener |> PGListener.subscribe (channelName table) \notification -> do
let pid = notification.notificationPid |> show |> cs
sendChunk (ByteString.stringUtf8 $
-- Follows the SSE message spec defined on MDN
-- https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format
"id:" <> pid <> "\n" <>
"event:" <> cs eventName <> "\n" <>
"data: " <> cs table <> " change event triggered\n\n")
Expand Down

0 comments on commit c21290e

Please sign in to comment.