Skip to content

Commit

Permalink
feature: wrap event payloads in ws
Browse files Browse the repository at this point in the history
Wrap the events' payloads in an object with fields
- event
- data
so that consuming them off the WebSocket is easier and
one can discern the type of the event explicitly instead
of implicitly fromt he payload content.
  • Loading branch information
tkurki committed Dec 27, 2023
1 parent 94020fb commit fcbc55f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function startEvents(
) {
const events = eventsFromQuery.split(',')
events.forEach((event) => {
app.on(event, onEvent)
app.on(event, (data: any) => onEvent({event, data}))
spark.onDisconnects.push(() => app.removeListener(event, onEvent))
})
}
Expand Down

0 comments on commit fcbc55f

Please sign in to comment.