param icon indicating copy to clipboard operation
param copied to clipboard

Document how to use with `layout.param.objects.rx`

Open ahuang11 opened this issue 11 months ago • 5 comments

I think the following should be documented in https://param.holoviz.org/user_guide/Reactive_Expressions.html

Instead of

self._coordinator.interface.param.objects.rx.bool().rx.not_()
    visible=self._coordinator.interface.param.objects.rx.bool().rx.not_()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'function' object has no attribute 'rx'

It should be:

self._coordinator.interface.param['objects'].rx.bool().rx.not_()

Because the param accessor works like a dataframe column accessors, if the parameter name clashes with an existing method the method takes precedence.

ahuang11 avatar Jan 08 '25 16:01 ahuang11

I'd rather suggest documenting this on this page https://param.holoviz.org/user_guide/Parameters.html. With a warning admonition letting people know that getattr will pick a method instead of a parameter when they clash and that getitem is the safer approach. Around the place where this is already partially documented.

Image

maximlt avatar Jan 10 '25 17:01 maximlt

I'd be fine with both, i.e. document it in Parameters and leave a short note in rx docs.

philippjfr avatar Jan 10 '25 17:01 philippjfr

I'd recommend both, or else it would seem rx only works with widgets and not layouts.

ahuang11 avatar Jan 10 '25 17:01 ahuang11

I'd recommend both, or else it would seem rx only works with widgets and not layouts.

I'm fine adding this warning in this page too but your comment makes me think it should be added to Panel too somewhere, since you're mentioning widgets and layouts. There's in fact a mention to Panel in this page so you could add the warning there, although it's towards the end.

Image

maximlt avatar Jan 10 '25 17:01 maximlt

When I was using it, I'd jump straight to this page for all rx knowledge, but yes having it in Panel would be nice

ahuang11 avatar Jan 10 '25 17:01 ahuang11