Change format of events sent by server, leveraging event type and id

This commit is contained in:
Deluan
2020-11-25 20:46:21 -05:00
parent cc5eaf4caf
commit b6c578e3a2
3 changed files with 46 additions and 47 deletions
+5 -11
View File
@@ -1,17 +1,11 @@
export const EVENT_SCAN_STATUS = 'EVENT_SCAN_STATUS'
export const EVENT_SERVER_START = 'EVENT_SERVER_START'
export const EVENT_SCAN_STATUS = 'scanStatus'
export const EVENT_SERVER_START = 'serverStart'
const actionsMap = {
scanStatus: EVENT_SCAN_STATUS,
serverStart: EVENT_SERVER_START,
}
export const processEvent = (data) => {
let type = actionsMap[data.name]
if (!type) type = data.name
export const processEvent = (type, event) => {
const data = JSON.parse(event)
return {
type,
data: data.data,
data: data,
}
}