mirror of
https://github.com/zadam/trilium.git
synced 2024-11-17 13:14:44 +08:00
36 lines
No EOL
679 B
JavaScript
36 lines
No EOL
679 B
JavaScript
const clsHooked = require('cls-hooked');
|
|
const namespace = clsHooked.createNamespace("trilium");
|
|
|
|
async function init(callback) {
|
|
return await namespace.runAndReturn(callback);
|
|
}
|
|
|
|
function wrap(callback) {
|
|
return async () => await init(callback);
|
|
}
|
|
|
|
function getSourceId() {
|
|
return namespace.get('sourceId');
|
|
}
|
|
|
|
function disableEntityEvents() {
|
|
namespace.set('disableEntityEvents', true);
|
|
}
|
|
|
|
function isEntityEventsDisabled() {
|
|
return !!namespace.get('disableEntityEvents');
|
|
}
|
|
|
|
function reset() {
|
|
clsHooked.reset();
|
|
}
|
|
|
|
module.exports = {
|
|
init,
|
|
wrap,
|
|
namespace,
|
|
getSourceId,
|
|
disableEntityEvents,
|
|
isEntityEventsDisabled,
|
|
reset
|
|
}; |