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

Invalidate TileSource cache on property changes #8594

Merged
merged 2 commits into from Jan 30, 2019

Conversation

philippjfr
Copy link
Contributor

@philippjfr philippjfr commented Jan 30, 2019

Upgrades TileSource attributes to properties and add events to clear cache and rerender when a property changes. Let me know if my assumption that attributes need to be properties to trigger model change events is wrong.

geoviews_tilesources_small

@bryevdv
Copy link
Member

bryevdv commented Jan 30, 2019

Let me know if my assumption that attributes need to be properties to trigger model change events is wrong.

This is true AFAIK @mattpap can comment if I am mistaken

@@ -52,6 +52,7 @@ export class TileRendererView extends RendererView {
connect_signals(): void {
super.connect_signals()
this.connect(this.model.change, () => this.request_render())
this.connect(this.model.tile_source.change, () => this.request_render())
Copy link
Member

Choose a reason for hiding this comment

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

So, what happens here if the tile source itself is swapped out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, in that case I guess it should unsubscribe from this event, and subscribe to the new tile source. Is that handled on the GlyphRenderer when swapping out the Glyph? I can't spot where that's done.

Copy link
Member

Choose a reason for hiding this comment

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

Hrm I am not actually sure it is handled currently though I thought it was in the past. I would be OK with merging this and making a follow on issue to investigate more thorough signal disconnect/reconnect (in general, for glyphs and this and anything else)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1

Would be neat if the property could detect a model was being replaced and then dis- and reconnect any signals that were attached to the model being replaced, instead of having to handle this reconnecting logic all over the place. I don't know enough to determine whether that's feasible though.

x_origin_offset: p.Property<number>
y_origin_offset: p.Property<number>
initial_resolution: p.Property<number>
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let me know if my assumption that attributes need to be properties to trigger model change events is wrong.

Yes and no. If you want automation, then yes. You may try to use setv() directly, but that will fail, if "properties" weren't defined. You can, however, emit change signal manually if you want (e.g. from a setter). I'm writing this in the context of the above change, because it isn't necessary in this PR (though useful in general). From runtime perspective only this.define(...) matters. Also note that define() is untyped currently, so you can put whatever you want there (which obviously I don't recommend).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the clarification, I think in this case it is needed because we want the model to be responsive to any change events, no matter how they were triggered.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, the default is to use properties, especially as the part of the API. However, I just want to make sure that it's understood that the code above doesn't have any run time implications. Any interfaces or types (or anything else that is part of TypeScript and not JavaScript) are fully erased at compilation time. The only thing that matters at runtime is define(), and that was fully specified already. But as I said, it doesn't harm to add this code (in fact I have a WIP PR that fills all those in), just I want to make sure that be benefits and consequences of such change are fully understood.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah okay, I did misunderstand you initially then. Thanks for clarifying, the only thing I'm missing is why attributes and properties seem to be duplicating the same type information. Wouldn't it be sufficient to declare them once as either attributes or as properties?

Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be sufficient to declare them once as either attributes or as properties?

Yes (*), however, limitations of the language when we started the transition didn't allow for this. Currently I can use mapped and conditional types, to generate attributes from properties (this direction, because properties carry more information than attributes). I have a WIP PR that fixes that (after layout). However, (*) attributes and properties may, and in fact do in case of specs, carry different types, or even input (constructor) and output (model interface) types may differ. Altogether this can get pretty tricky, but with some type-level magic it can be handled without duplication.

Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be sufficient to declare them once as either attributes or as properties?

Just to add more color: the duplication is entirely because we developed a properties system in coffee script, if we had had the current version of typescript at the time we probably could have done else. Now we have the task of unifying our old sort-of-types with TypieScript's actual language capabilities, and that is an onerous task.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the background, I really appreciate it.

@philippjfr
Copy link
Contributor Author

@bryevdv Should we merge this or do you want me to take some action on the tile source replacement issue?

@bryevdv
Copy link
Member

bryevdv commented Jan 30, 2019

No I will merge now, please make a follow up issue about the other.

@bryevdv bryevdv merged commit 989ddb5 into master Jan 30, 2019
@bryevdv bryevdv deleted the philippjfr/8164_tile_cache_invalidation branch January 30, 2019 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TileRenderer cache is not invalidated when URL changes
3 participants