-
Notifications
You must be signed in to change notification settings - Fork 166
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
RFC: Ensure emission of signals only after an operation is done, and only due to operations #866
base: master
Are you sure you want to change the base?
RFC: Ensure emission of signals only after an operation is done, and only due to operations #866
Conversation
Build succeeded. |
* @return {undefined} | ||
*/ | ||
this.emitSignalCursorMoved = function(cursor) { | ||
eventNotifier.emit(ops.Document.signalCursorMoved, cursor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one and the undo stack modification definitely should be queued up when called via an operation. This one especially is one of the most frequent causes of the bug this patch is trying to fix.
I would instead suggest passing in the events array into function calls that need to generate signals, as there are a limited number of these.
For the specific edge case that is the shadow cursor, perhaps you can inject or expose a specialised callback to be used ONLY by the shadow cursor. This ensures operations don't get access to the these inappropriate methods.
Ah, right, I see that you've only moved the shadow cursor across to this. That means there are a bunch of yet-unfixed eventNotifier calls still in this class (e.g., moveCursor & fixCursorPositions) that fixCursorPositions still require fixing.
Overall, I'm actually 100% ok with this. The key fixes I'd like to see are:
|
41078f7
to
d34edc9
Compare
d34edc9
to
ff1317e
Compare
ff1317e
to
cce2827
Compare
These events feed straight into the steps cache, and must be processed by the cache before any external consumers receive the event.
Also merge creator metadata update signal into any existing metadata update signal
cce2827
to
5bde046
Compare
964f381
to
9534f81
Compare
Played with some code for getting all events added to operations queue. Not thrilled with the result yet, but possible a step into the right direction. |
Build succeeded. |
This is an alternative proposal for the problem first approached with #827:
implementations of operations emitting signals from the document before the operation has completed.
It is different from the first approach as it is more radical (in principle, exceptions needed still due to existing code):
no more can anyone emit a signal in the name of the
OdtDocument
whenever they want. Instead during the execution of an operation all events about changes on the document are collected, and when the execution has been completed, these events are all emitted in one go. Which also means that only by operation execution signals can be emitted.Basic idea is:
only operations should modify the state of the document and thus events/signals be created
By encapsulating the operation execution and signal emission in code not influencable by the 3rd-party programmer, there is also no chance to do hacky emissions of signals.
emitSignalCursorMoved
,emitSignalUndoStackChanged
had to be added to deal with current hacks in the code, but hopefully in the future can be removed.fixCursorPositions
also emits custom signals, yet to be solved.Not yet sure if this is a sane approach and should be guiding the way into the future. So putting here mainly as a RFC for now, nothing I would like to see merged already yesterday. But then I hope latest March we found out what to do with this :)