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

added _view_count trait to Widget, to count the number of views #1232

Merged
merged 3 commits into from
Apr 4, 2017

Conversation

maartenbreddels
Copy link
Member

added _view_count trait to Widget, to count the number of views in the backend, as discussed here: #1225

There seems to be an issue with the Output widget, it only sends it state once, subsequent calls to OutputModel.save() or OutputModel.save_changes() do nothing. I'm not sure what is so different about OutputModel.

I also noticed WidgetView.remove() was called twice, I'll submit an issue for that, I've worked around that by using .once(..).

@@ -247,6 +247,8 @@ def get_view_spec(self):
help="Name of the view object.").tag(sync=True)
_view_module_version = Unicode('*',
help="A semver requirement for the view module version.").tag(sync=True)
_view_count = Int(read_only=True,
help="The number of views accociated to the model at the front-end").tag(sync=True)
Copy link
Member

Choose a reason for hiding this comment

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

"associated". Also, can we indicate this is experimental for now? Maybe "EXPERIMENTAL: The number of views of the model displayed in the frontend. This attribute is experimental and may change or be removed in the future."

@@ -623,6 +623,19 @@ abstract class WidgetView extends NativeView<WidgetModel> {
this.listenTo(this.model, 'change', this.update);

this.options = parameters.options;

this.once('remove', () => {
console.log("remove view count", this.model.get('_view_count'), this.model.get('_view_count') -1)
Copy link
Member

Choose a reason for hiding this comment

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

delete the console.log

});

this.once('displayed', () => {
console.log("add view count", this.model.get('_view_count'), this.model.get('_view_count') +1)
Copy link
Member

Choose a reason for hiding this comment

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

delete the console.log

@maartenbreddels
Copy link
Member Author

I assume you are ok with merging this, I'll add those comments and remove the logs. It would take some debugging to see why Output is misbehaving though, but that bug/feature can't be in this code I think. I hope to update this soon.

@jasongrout
Copy link
Member

I assume you are ok with merging this, I'll add those comments and remove the logs.

Yes, I'm okay merging this as an experimental feature.

@jasongrout
Copy link
Member

Thanks again for pushing forward on things!

@jasongrout jasongrout merged commit 174f525 into jupyter-widgets:master Apr 4, 2017
@jasongrout
Copy link
Member

Thanks!

@maartenbreddels maartenbreddels deleted the _view_count branch April 5, 2017 07:30
@maartenbreddels
Copy link
Member Author

Looking forward to the next release ! :)

@jasongrout jasongrout modified the milestone: 7.0 Apr 11, 2017
@github-actions github-actions bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Feb 15, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants