-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Conversation
src/util/evented.js
Outdated
// determine if source is loaded when event is fired | ||
if (typeof data.isSourceLoaded === "function") { | ||
data.isSourceLoaded = data.isSourceLoaded(); | ||
}; |
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.
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.
a1d941a
to
25f4742
Compare
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 |
@@ -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)); |
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.
Could you add a test that ensures the eventedParentData
function is called per emit and passes on the latest & greatest data?
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.
Looks good otherwise 😄
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.
Great -- added a test!
6f71c8d
to
820f37f
Compare
Working on fixing evaluation of
MapEventData#isSourceLoaded
Fixes #3958
Questions:
We only fire a
data
event withdataType: source
when the TileJSON is loaded, butisSourceLoaded: true
only occurs after all the tiles in for the source in the current viewport are loaded, so fordataType:source
EventData#isSourceLoaded
is still nevertrue
. Should we fire anotherdata
event of typesource
when all tiles are loadedisSourceLoaded
flips totrue
?cc @lucaswoj @anandthakker @lbud
Launch Checklist