Skip to content

Provide more control over the call order of watched methods #618

Description

@sdc50

Between versions 1.11.1 and 1.12.1 the order in which methods that are decorated with param.depends are triggered was changed.

In [1]: import param

In [2]: class Test(param.Parameterized):
   ...:     s = param.String(default='default')
   ...: 
   ...:     @param.depends('s', watch=True)
   ...:     def on_s_update(self):
   ...:         print(self.s)
   ...: 
   ...: class Sub(Test):
   ...: 
   ...:     @param.depends('s', watch=True)
   ...:     def more_on_s_update(self):
   ...:         print(self.s.upper())
   ...: 
   ...: s = Sub()
   ...: s.s = 'test'
test
TEST

In [3]: param.__version__
Out[3]: '1.11.1'

vs.

image

Without a way to explicitly control the call order much of my code was in a delicate balance, and this has just wreaked havoc on it all.

There should be a way explicitly control the call order of depended on methods. In the past I had discussed with @philippjfr about adding a precedence argument to the depends decorator (and the watch method) so that callbacks can be sorted and called in a specified order when a parameter is triggered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions