trilium/src/services/cls.js

36 lines
679 B
JavaScript
Raw Normal View History

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);
}
2018-03-31 01:20:36 +08:00
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,
2018-03-31 01:20:36 +08:00
namespace,
getSourceId,
disableEntityEvents,
isEntityEventsDisabled,
reset
};