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

commented Mar 28, 2017

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)

This comment has been minimized.

Copy link
@jasongrout

jasongrout Apr 3, 2017

Member

"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)

This comment has been minimized.

Copy link
@jasongrout

jasongrout Apr 3, 2017

Member

delete the console.log

});

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

This comment has been minimized.

Copy link
@jasongrout

jasongrout Apr 3, 2017

Member

delete the console.log

@maartenbreddels

This comment has been minimized.

Copy link
Member Author

commented Apr 3, 2017

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

This comment has been minimized.

Copy link
Member

commented Apr 4, 2017

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

This comment has been minimized.

Copy link
Member

commented Apr 4, 2017

Thanks again for pushing forward on things!

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

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@jasongrout

This comment has been minimized.

Copy link
Member

commented Apr 4, 2017

Thanks!

@maartenbreddels maartenbreddels deleted the maartenbreddels:_view_count branch Apr 5, 2017

@maartenbreddels

This comment has been minimized.

Copy link
Member Author

commented Apr 5, 2017

Looking forward to the next release ! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.