Skip to content

Commit d05210d

Browse files
author
Dierk Koenig
committed
observable.js: lazy init of logger to go around bidirectional dependency issues.
1 parent be1f449 commit d05210d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/src/kolibri/observable.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import { LOG_CONTEXT_KOLIBRI_BASE } from "./logger/logConstants.js";
44

55
export {Observable, ObservableList}
66

7-
const { warn } = LoggerFactory(LOG_CONTEXT_KOLIBRI_BASE + ".observable");
8-
7+
let warn = undefined;
98
/** @private */
109
function checkWarning(list) {
1110
if (list.length > 100) {
11+
if (!warn) {
12+
warn = LoggerFactory(LOG_CONTEXT_KOLIBRI_BASE + ".observable").warn;
13+
}
1214
warn(`Beware of memory leak. ${list.length} listeners.`);
1315
}
1416
}

0 commit comments

Comments
 (0)