-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save callback is triggered too often (when nothing changes) #2547
Comments
I implemented throttling, while that's more like debouncing with the maximum waiting time set. The current implementation can be changed of course. Your proposal combined with https://github.com/ckeditor/ckeditor5-autosave/issues/9 will make the server calls rare. As I remember, that was a reason before for using the throttle and synchronous first call, but now it makes little sense. |
What we want to have is debounce, see: Save should be executed when the user stops editing (~1-2sec after the last change event, need to be tested, it should not be too often but also the user should not wait noticeably long for the saving action). In the F2F talk, we agreed that in the first implementation we do not need any save action while the user is editing (change action is fired often). We believe that the user does pause and it is the best moment to save the data. However, the pending action should be added as soon as the user do the first change, so he will see a warning when trying to exit with data not saved. |
So you're right regarding what debounce is :D I'll never remember which is which :P |
BTW, does it mean that we may be able to use lodash's implementation? Would be nice if we could. |
I think so. That's because there will be only one saving action at a time. The plugin might be in only 3 states: I'll describe the scenario below: When there's no action and a new When the plugin is in the When the Once it gets the response from the server, it can perform two actions: If there's no stored information about a new change, it changes the state to the first, If there's an information about a new change, it changes the state to the Does it make sense for you? |
Can we just update lodash version we use? |
It'd be perfect, at least for now. I can check if tests will pass with the updated library. |
Other: Improved call frequency. Closes #9. Closes #10. Closes #12. Closes ckeditor/ckeditor5#1158.
The save callback is executed twice with the same content in a short period of time. I think that this is due to a flawed implementation of the
throttle()
function.Disclaimer: I never remember which is throttling and which is debouncing, so I'll use the word throttle, but please read what's the expected semantics of it and don't focus on the name.
The throttling in autosave should work like this:
X may equal Y, but ideally they should be independent. It makes sense to make Y longer so you don't constantly save things while a person is typing. Typically, I'd set X=1s, Y=5s (or even more).
How the current implementation seems to work is this:
And the first point makes for the first "Saving... foo" while the second for another "Saving... foo".
The text was updated successfully, but these errors were encountered: