mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
all events are now synchronous
This commit is contained in:
parent
9fb0599c45
commit
c78ddb70cb
@ -65,7 +65,7 @@ async function loginToProtectedSession(req) {
|
|||||||
// this is set here so that event handlers have access to the protected session
|
// this is set here so that event handlers have access to the protected session
|
||||||
cls.namespace.set('protectedSessionId', protectedSessionId);
|
cls.namespace.set('protectedSessionId', protectedSessionId);
|
||||||
|
|
||||||
eventService.emit(eventService.ENTER_PROTECTED_SESSION);
|
await eventService.emit(eventService.ENTER_PROTECTED_SESSION);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
|
@ -9,18 +9,7 @@ function subscribe(eventType, listener) {
|
|||||||
eventListeners[eventType].push(listener);
|
eventListeners[eventType].push(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
function emit(eventType, data) {
|
async 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) {
|
|
||||||
const listeners = eventListeners[eventType];
|
const listeners = eventListeners[eventType];
|
||||||
|
|
||||||
if (listeners) {
|
if (listeners) {
|
||||||
@ -33,7 +22,6 @@ async function syncEmit(eventType, data) {
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
subscribe,
|
subscribe,
|
||||||
emit,
|
emit,
|
||||||
syncEmit,
|
|
||||||
// event types:
|
// event types:
|
||||||
NOTE_TITLE_CHANGED,
|
NOTE_TITLE_CHANGED,
|
||||||
ENTER_PROTECTED_SESSION,
|
ENTER_PROTECTED_SESSION,
|
||||||
|
@ -53,7 +53,7 @@ async function addEntitySync(entityName, entityId, sourceId) {
|
|||||||
sourceId: sourceId || cls.getSourceId() || sourceIdService.getCurrentSourceId()
|
sourceId: sourceId || cls.getSourceId() || sourceIdService.getCurrentSourceId()
|
||||||
});
|
});
|
||||||
|
|
||||||
await eventService.syncEmit(eventService.ENTITY_CHANGED, {
|
await eventService.emit(eventService.ENTITY_CHANGED, {
|
||||||
entityName,
|
entityName,
|
||||||
entityId
|
entityId
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user