Skip to content
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

MapEventData#isSourceLoaded fix #4254

Merged
merged 5 commits into from
Feb 21, 2017
Merged

MapEventData#isSourceLoaded fix #4254

merged 5 commits into from
Feb 21, 2017

Conversation

mollymerp
Copy link
Contributor

@mollymerp mollymerp commented Feb 10, 2017

Working on fixing evaluation of MapEventData#isSourceLoaded

Fixes #3958

Questions:
We only fire a data event with dataType: source when the TileJSON is loaded, but isSourceLoaded: true only occurs after all the tiles in for the source in the current viewport are loaded, so for dataType:source EventData#isSourceLoaded is still never true. Should we fire another data event of type source when all tiles are loaded isSourceLoaded flips to true ?

cc @lucaswoj @anandthakker @lbud

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page

// determine if source is loaded when event is fired
if (typeof data.isSourceLoaded === "function") {
data.isSourceLoaded = data.isSourceLoaded();
};
Copy link
Contributor

Choose a reason for hiding this comment

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

An alternative to this approach might be to change the semantics of Evented#setEventedParent() so that, if the evented parent data parameter is a function, it is evaluated during fire() rather than during setEventedParent().

On the surface, that seems preferable to me because it avoids the hardcoding here... but it would require a review of setEventedParent to make sure we aren't counting on data being evaluated immediately anywhere else.

@mollymerp
Copy link
Contributor Author

to keep the scope of this PR under control, I suggest we ship this fix as-in and I will handle a larger rejiggering of the source data event in a separate PR.

@@ -82,7 +81,7 @@ class Evented {
}

if (this._eventedParent) {
this._eventedParent.fire(type, util.extend({}, data, this._eventedParentData));
this._eventedParent.fire(type, util.extend({}, data, typeof this._eventedParentData === 'function' ? this._eventedParentData() : this._eventedParentData));
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a test that ensures the eventedParentData function is called per emit and passes on the latest & greatest data?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good otherwise 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great -- added a test!

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.

MapDataEvent#isSourceLoaded always returns false
3 participants