Support named and positional arguments on bound Parameterized methods
- Dominant language
- Python
- Stars
- 521
- Forks
- 86
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 35
Description
If you have a standalone function you can do
```view
@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.
```python
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()
```

```bash
TypeError: view() missing 2 required positional arguments: 'value1' and 'value2'
```
Enabling this would make it easier to
1. reason about which parameters are being using in the method.
2. Use the values
3. Refactor code between functional and class based
4. 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.
```python
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 😄
```python
@param.react(value1="value1", value2="value2", watch=True)
def view(self, value1, value2, set_parameters):
set_parameters(value1=10)
```
Contributor guide
Assessment
This issue has not been assessed yet.