-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Ensure class watchers are not inherited by instance parameter #833
Conversation
# Reset watchers since class parameter watcher should not execute | ||
# on instance parameters | ||
p.watchers = {} | ||
|
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.
That's a very pleasing simplification! Hope it will work well in practice.
So it turns out the copying was effectively a hack to allow watchers that are set up during instance creation (i.e. primarily ones set up using |
I ran Panel and HoloViews unit test suites successfully against this branch. Merging, thanks! |
In #826 we discovered some weird logic that was copying over watchers from class to instance parameters. After discussing this we all agreed this does not make sense, this is because slots are not shared between class and instance parameters and therefore it does not make sense that an instance parameter would inherit the watchers from a completely different
Parameter
instance. Worse yet, once an instance was created the watcher would be removed from the class which means that modifying the classParameter
slot value would no longer trigger the watcher.The correct behavior is actually quite simple, watchers should not be copied over, instead the
Parameter
slot watchers should be reset when the instance parameter is created. This ensure that while the instance still shares theParameter
object with the class it correctly fires if a slot on the class Parameter is changed and when an instance parameter is created only newly created watchers on the instance will be watched. Since callinginst.param.watch
will automatically create instance parameters for any parameters that are watched this means that the behavior will be correct in all cases both instances and classes will always correctly trigger the appropriate watchers.Fixes #829