Skip to content

add getter and setter for renderWorldCopies - #5944

Merged
andrewharvey merged 4 commits into
masterfrom
4039-get-set-renderworldcopies
Feb 13, 2018
Merged

andrewharvey merged 4 commits into
masterfrom
4039-get-set-renderworldcopies

Conversation

@andrewharvey

Copy link
Copy Markdown
Collaborator

Closes #4039

Launch Checklist

  • briefly describe the changes in this PR

Adds a getter and setter for renderWorldCopies so it can be changed after map initialisation.

  • write tests for all new functionality

Unit tests confirm the getter and setters are in sync.

  • document any changes to public APIs

JS doc included

  • post benchmark scores
  • manually test the debug page

I've manually tested flipping renderWorldCopies and it updates the visuals correctly.

@andrewharvey
andrewharvey force-pushed the 4039-get-set-renderworldcopies branch from 099c767 to a1032ee Compare January 4, 2018 03:31

@mourner mourner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it failed the Flow checks

@andrewharvey

Copy link
Copy Markdown
Collaborator Author

I think I need some help here!

I guess Flow doesn't like that you can call setRenderWorldCopies with null/undefined given it expects a boolean.

However it's important to have the setter consistant with setting via map initialisation, which is ensured by this PR.

setRenderWorldCopies(null) is like false just like renderWorldCopies: null
setRenderWorldCopies(undefined) is like true just like renderWorldCopies: undefined
setRenderWorldCopies() is like true just like omitting renderWorldCopies as the map option.

I just added a second commit to make Flow happy but now eslint doesn't like it. Any suggestions on what I can do?

@andrewharvey

Copy link
Copy Markdown
Collaborator Author

I've added another commit which explicitly handles null and undefined in the same way as the initialiser. Not sure if this is the right way of doing it but it makes Flow happy and gives the expected outcomes.

I didn't want to get too bogged down in corner cases like passing null and undefined and would be happy with forcing passing either a true or a false to the setter, but I guess it's good to keep it consistent with the initialiser.

@mollymerp mollymerp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay here @andrewharvey ! This looks good to me – thanks for working to appease Flow; it can certainly be tricky sometimes.

Tested the debug page and the docs 👍

Maybe indicate in the docs what happens in the cases of null or undefined ?

@andrewharvey

Copy link
Copy Markdown
Collaborator Author

Maybe indicate in the docs what happens in the cases of null or undefined ?

I've added this to the documentation and also included test cases for this since it's now documented.

@andrewharvey
andrewharvey merged commit cd4a19b into master Feb 13, 2018
@andrewharvey
andrewharvey deleted the 4039-get-set-renderworldcopies branch February 13, 2018 03:16
pathmapper pushed a commit to pathmapper/mapbox-gl-js that referenced this pull request Feb 13, 2018
pathmapper pushed a commit to pathmapper/mapbox-gl-js that referenced this pull request Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants