param.reactive.reactive_ops.pipe#
- reactive_ops.pipe(func, /, *args, **kwargs) rx[source]#
Apply a chainable function to the current reactive value.
This method allows applying a custom function to the current reactive expression. The result is returned as a new reactive expression, making it possible to create dynamic and chainable pipelines.
- Parameters:
func (callable) – The function to apply to the current value.
*args (iterable, optional) – Positional arguments to pass to the function.
**kwargs (dict, optional) – Keyword arguments to pass to the function.
- Returns:
A new reactive expression representing the result of applying
func.- Return type:
Examples
Apply a custom function to transform a reactive value:
>>> import param >>> rx_value = param.rx(10) >>> rx_result = rx_value.rx.pipe(lambda x: x * 2) >>> rx_result.rx.value 20
Use positional arguments with the function:
>>> def add(x, y): ... return x + y >>> rx_result = rx_value.rx.pipe(add, 5) >>> rx_result.rx.value 15
Use keyword arguments with the function:
>>> def multiply(x, factor=1): ... return x * factor >>> rx_result = rx_value.rx.pipe(multiply, factor=3) >>> rx_result.rx.value 30