Support named and positional arguments on bound Parameterized methods
If you have a standalone function you can do
@pn.depends(value1=object1.param.value, value2=object2.param.value)
def view(value1, value2):
...
But if its a class method you cannot have named or positional arguments.
import panel as pn
import param
pn.extension()
class Custom(param.Parameterized):
value1 = param.String()
value2 = param.String()
@param.depends("value1", "value2")
def view(self, value1, value2):
return value1+value2
custom=Custom()
pn.Column(custom.view, pn.Param(custom)).servable()

TypeError: view() missing 2 required positional arguments: 'value1' and 'value2'
Enabling this would make it easier to
- reason about which parameters are being using in the method.
- Use the values
- Refactor code between functional and class based
- write in a reactive style ala react.
I would prefer this change would be implemented down to the param level.
Additional Context
If you added the posibility to provide a set_parameters function you would be able to develop in the React style of Idom and Solara.
import panel as pn
import param
pn.extension()
class Custom(param.Parameterized):
value1 = param.String()
value2 = param.String()
@param.depends(value1="value1", value2="value2", react=True, watch=True)
def view(self, value1, value2, set_parameters):
....
set_parameters(value1=10)
If you simplified we could have yet another api 😄
@param.react(value1="value1", value2="value2", watch=True)
def view(self, value1, value2, set_parameters):
set_parameters(value1=10)
@MarcSkovMadsen could you explain what react and set_parameters is supposed to do?
The reactive programming style consist of providing 1) the state 2) a function to update the state.
set_parameters is the function 2) to update the state.
react makes sure the set_parameters function is provided as input
I like the idea of allowing the keyword specification to tell it to pass the parameters in explicitly but I absolutely don't follow the point of the react thing. Why would we provide set_parameters if you can simply do self.param.update(value1=10)?
So currently I'm a strong -1 on react=True and @param.react() but may be missing something.
The reason why I mention the react api is that there are some supply and demand for react apis. And we spend resources on supporting that via Idom and Reacton. So why does Param/Panel not just provide a built in react api.
Its not currently important to me personally. The named arguments to the function is.