Skip to content

Commit

Permalink
observable.js: lazy init of logger to go around bidirectional depende…
Browse files Browse the repository at this point in the history
…ncy issues.
  • Loading branch information
Dierk Koenig committed Dec 8, 2024
1 parent be1f449 commit d05210d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/src/kolibri/observable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { LOG_CONTEXT_KOLIBRI_BASE } from "./logger/logConstants.js";

export {Observable, ObservableList}

const { warn } = LoggerFactory(LOG_CONTEXT_KOLIBRI_BASE + ".observable");

let warn = undefined;
/** @private */
function checkWarning(list) {
if (list.length > 100) {
if (!warn) {
warn = LoggerFactory(LOG_CONTEXT_KOLIBRI_BASE + ".observable").warn;
}
warn(`Beware of memory leak. ${list.length} listeners.`);
}
}
Expand Down

0 comments on commit d05210d

Please sign in to comment.