Open rauschma opened 6 months ago
There's already a debounce function. The debounce time is determined dynamically as follows:
var elapsedTime = endTime - startTime;
debounceMs = elapsedTime * 8;
The factor could be increased, but it doesn't feel laggy to me.
Ah, I should have checked other browsers:
Interesting. I use it with Safari on M1 mac and have no issues.
You can try editing the code locally and changing that 8 to a higher number?
Also try with a large file and make sure the debounce is kicking in. When I try it with 240K file, I see exactly the behavior you're requesting -- I type and then when I stop, it renders. That's because the debounce time is determined dynamically based on how long it takes to parse and render the document.
Currently, typing is slowed down. Does the code parse and render after every keystroke?
If yes then you could wait until the user pauses typing – e.g., like this: