-
Notifications
You must be signed in to change notification settings - Fork 5
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
Refactor updating scorecard #169
Refactor updating scorecard #169
Conversation
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.
Nice! Although technically this isn't a refactor because there is a behavior change for end users. Refactors are when the end behavior is the same and you only change how the code is implemented.
src/js/setUpSite.js
Outdated
const snapToCity = async (map, cityProperties) => { | ||
const { layer } = cityProperties; |
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.
It's better to directly take the layer
as the argument since it's the only part of cityProperties
that you use. Callers would pass cityProperties.layer
as the argument.
There shouldn't bee a behavior change for the end user. Is there one that you noticed? |
Didn't it change like this?
My understanding of the code is that you now call |
src/js/setUpSite.js
Outdated
* Centers view to city. | ||
* | ||
* @param map: The Leaflet map instance. | ||
* @param cityProperties: An object with a `layout` key (Leaflet value) and keys |
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.
Outdated
|
Yes, but the end user experience doesn't/shouldn't change. |
Why this refactor?
This simplifies when scorecard updates.
Before, there were many different cases in which a scorecard would update, like the dropdown changing, the user panning to a different city, or the user clicking on a city.
Now, the scorecard only updates to the city closes to the center of the screen. So, when the dropdown changes, the map snaps to city, which will also automatically update the scorecard.