Jelajahi Sumber

Comment debounced calls

Sebastien Lebreton 5 tahun lalu
induk
melakukan
a08282a873
1 mengubah file dengan 3 tambahan dan 0 penghapusan
  1. 3 0
      Playground/js/monacoCreator.js

+ 3 - 0
Playground/js/monacoCreator.js

@@ -326,6 +326,9 @@ class MonacoCreator {
         this.jsEditor = monaco.editor.create(document.getElementById('jsEditor'), editorOptions);
         this.jsEditor.setValue(oldCode);
 
+        // We cannot call 'analyzeCode' on every keystroke, that's time consuming
+        // So use a debounced version to prevent over processing.
+        // Be careful to keep the proper context for the effective call (this).
         const analyzeCodeDebounced = this.parent.utils.debounceAsync((async) => this.analyzeCode(), 500);
 
         this.jsEditor.onDidChangeModelContent(function () {