all events are now synchronous

This commit is contained in:
azivner 2018-08-12 20:07:02 +02:00
parent 9fb0599c45
commit c78ddb70cb
3 changed files with 3 additions and 15 deletions

View file

@ -65,7 +65,7 @@ async function loginToProtectedSession(req) {
// this is set here so that event handlers have access to the protected session
cls.namespace.set('protectedSessionId', protectedSessionId);
eventService.emit(eventService.ENTER_PROTECTED_SESSION);
await eventService.emit(eventService.ENTER_PROTECTED_SESSION);
return {
success: true,

View file

@ -9,18 +9,7 @@ function subscribe(eventType, listener) {
eventListeners[eventType].push(listener);
}
function emit(eventType, data) {
const listeners = eventListeners[eventType];
if (listeners) {
for (const listener of listeners) {
// not awaiting for async processing
listener(data);
}
}
}
async function syncEmit(eventType, data) {
async function emit(eventType, data) {
const listeners = eventListeners[eventType];
if (listeners) {
@ -33,7 +22,6 @@ async function syncEmit(eventType, data) {
module.exports = {
subscribe,
emit,
syncEmit,
// event types:
NOTE_TITLE_CHANGED,
ENTER_PROTECTED_SESSION,

View file

@ -53,7 +53,7 @@ async function addEntitySync(entityName, entityId, sourceId) {
sourceId: sourceId || cls.getSourceId() || sourceIdService.getCurrentSourceId()
});
await eventService.syncEmit(eventService.ENTITY_CHANGED, {
await eventService.emit(eventService.ENTITY_CHANGED, {
entityName,
entityId
});