Make sure Launch Bar Manager sends event at a correct time#1486
Make sure Launch Bar Manager sends event at a correct time#1486DangMinhTam382 wants to merge 2 commits into
Conversation
When active descriptor changed, and fireActiveLaunchDescriptorChanged() is called, current active mode and target are out of sync. This puts listeners at risk of handling event with false data for the changed descriptor. Changed it so that only fire event when related fields are finished updating
|
Hi Mr. @betamaxbandit , Before making this PR official, could you take a quick look and let me know what you think? Thanks! |
| // Set active mode | ||
| syncActiveMode(); | ||
| // Send notifications | ||
| fireActiveLaunchDescriptorChanged(); |
There was a problem hiding this comment.
Just moving this doesn't really solve the issue, the events for target & mode are still sent too early. This was why I suggested we create a new event that was for when any of them changed then we can just fire that once
There was a problem hiding this comment.
Thanks for the comment, Mr. @Kummallinen
About your suggestion, I did spend quite some time testing it out.
Tried posting a "LaunchBarChanged" event at the very end of these 3 methods: "setActiveLaunchDescriptor()", "setActiveLaunchMode()", "setActiveLaunchTarget()".
And it worked.
Then I realized that existing events "activeLaunchTargetChanged" & "activeLaunchModeChanged" are sent at the same point as the newly added event. The only exception is "activeLauchDescriptorChanged", which is fired too early.
With the changes in this commit, all three existing events and the new event are sent at the same time.
From an event-handling perspective, there is no noticeable difference between the existing events and the new event. That's why I decided to go with the approach in this commit.
--
About your concern:
the events for target & mode are still sent too early
Since "syncActiveTarget()" and "syncActiveMode()" is calling to "setActiveLaunchMode()" and "setActiveLaunchTarget()", respectively, the change events would still be fired too early even with the new event.
-> Possible suggestion to fix for this would be creating internal method that does NOT fire event,
Ex:
"syncActiveTarget()" -> "internalSetActiveLaunchTarget()" -> "internalSetActiveLaunchMode()"
However, this would be a much larger change and could potentially impact existing ISV implementations that relies on the current event behavior.
Therefore, instead of trying to ensure that events are fired at desired time, this commit focuses on ensuring that all Launch Bar components are up to date when a change event is fired/caught, even if the triggering method has not yet finished executing.
When active descriptor changed, and fireActiveLaunchDescriptorChanged() is called, current active mode and target are out of sync. This puts listeners at risk of handling event with false data for the changed descriptor.
Changed it so that only fire event when related fields are finished updating