looshi / Blaze-Haus

Edit blaze templates and css at runtime
6 stars 0 forks source link

Debounce Codemirror input #14

Closed looshi closed 9 years ago

looshi commented 9 years ago

Currently every single "change" event on a CodeMirror instance invokes a database change, which is extremely inefficient, but very convenient for the time being.

The goal of this ticket is to enhance the system performance with respect to saving changes so that :

  1. The editor still sees their edits applied to the rendered Template upon making each edit.
  2. The changes are sent to the database after a debounce interval.
  3. The template is not re-rerendered after the current user has made changes, however other users editing the same template will see the template re-rererendered due to the data change.
  4. If the changes fail to save, the current user should receive feedback that their changes could not be saved.

the point is , not every single keystroke should trigger a system update. https://github.com/looshi/Meteor-Live-Template-Editor/blob/master/client/views/inspector/Inspector.js#L149

looshi commented 9 years ago

The debounce may be able to go in this overriden handler inside the TextEditor : https://github.com/looshi/Meteor-Live-Template-Editor/blob/master/client/views/template-editor/TextEditor.js#L52 that way we can just debounce all text input in one place.

looshi commented 9 years ago

added a debounce and also put a debounce flag inside the TextEditor internal handler, so the event can be switched on and off