structured reload trigger

This commit is contained in:
Jan Prochazka
2022-12-25 15:35:56 +01:00
parent 1eea117062
commit 783f26b500
8 changed files with 73 additions and 64 deletions

View File

@@ -1,4 +1,5 @@
const _ = require('lodash');
const stableStringify = require('json-stable-stringify');
const sseResponses = [];
let electronSender = null;
@@ -27,12 +28,12 @@ module.exports = {
electronSender.send(message, data == null ? null : data);
}
for (const res of sseResponses) {
res.write(`event: ${message}\ndata: ${JSON.stringify(data == null ? null : data)}\n\n`);
res.write(`event: ${message}\ndata: ${stableStringify(data == null ? null : data)}\n\n`);
}
},
emitChanged(key) {
emitChanged(key, params = undefined) {
// console.log('EMIT CHANGED', key);
this.emit('changed-cache', key);
this.emit('changed-cache', { key, ...params });
// this.emit(key);
},
};