holoviz / param

Param: Make your Python code clearer and more reliable by declaring Parameters
https://param.holoviz.org
BSD 3-Clause "New" or "Revised" License
434 stars 74 forks source link

Add .set or .update method to reactive expression #956

Open MarcSkovMadsen opened 4 months ago

MarcSkovMadsen commented 4 months ago

I often have the need to update a reactive expression. Over and over again I find that I lack a .set or .update method. I need that to be able to update via callbacks, .bind or in lambda expressions. Its friction I have to create a set or update function my self.

Please add a .set method.

expression.rx.set(value) # same effect as expression.rx.value=value

Could be used as

button.on_click(expression.rx.set)

Additional Context

This is also what React does. Provides a set_value function.

philippjfr commented 4 months ago

We originally had this but then removed it because .rx.value setting seemed enough but I'd agree. Having a way to update the value with an expression rather than a statement adds a lot of convenience.