This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
fix: layer select state not update properly #268
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR fix three issues:
When create a new layer by drop the layer in Earth Editor, it doesn't got auto selected (No indicator shown on map).
useUpdate
with an internal implemtation (which refers to the source code of useUpdate but expose the state) and use the state as the dependence ofselectedLayer
.When unselect a layer the plugin api
select
doesn't emit (the plugin will not be noticed as unselect).undefined
is also meaningful and also should emit event to notice plugin there's no selected object.Plugin API event
select
cameramove
emitted too much (not as expected i think).args
(used as dependency ofuseEffect
insideuseEmit
) is something like[camera]
or[selectedLayer.id]
which would be differect in each update and make the side effect trigger every time. For example if you addcameramove
event from API then when you change any state eg. change scene background color you'll find the event also emitted. Also if you add aselect
event and select a layer then when you move camera theselect
event keeps emitting.What I've done
useUpdate
with a internal implement and use its state asselectedLayer
's dependency.undefined
to[undefined]
in order to emit plugin api select event when unselect.[camera]
and[selectedLayer.id]
to avoid unnecessary emit.What I haven't done
How I tested
select
mousemove
event from plugin and watch the event emit.Screenshot
Which point I want you to review particularly
Memo