param.reactive.reactive_ops#

class param.reactive.reactive_ops(reactive)[source]#

The reactive operations namespace.

Provides reactive versions of operations that cannot be made reactive through operator overloading. This includes operations such as .rx.and_ and .rx.bool.

Calling this namespace (()) creates and returns a reactive expression, enabling dynamic updates and computation tracking.

Returns:

A reactive expression representing the operation applied to the current value.

Return type:

rx

References

For more details, see the user guide: https://param.holoviz.org/user_guide/Reactive_Expressions.html#special-methods-on-rx

Examples

Create a Parameterized instance and access its reactive operations property:

>>> import param
>>> class P(param.Parameterized):
...     a = param.Number()
>>> p = P(a=1)

Retrieve the current value reactively:

>>> a_value = p.param.a.rx.value

Create a reactive expression by calling the namespace:

>>> rx_expression = p.param.a.rx()

Use special methods from the reactive ops namespace for reactive operations:

>>> condition = p.param.a.rx.and_(True)
>>> piped = p.param.a.rx.pipe(lambda x: x * 2)
__init__(reactive)[source]#

Methods

__init__(reactive)

and_(other)

Perform a logical AND operation with the given operand.

bool()

Evaluate the truthiness of the current object.

buffer(n)

Collect the last n items emitted by the reactive expression.

in_(other)

Check if the current object is contained "in" the given operand.

is_(other)

Perform a logical "is" comparison with the given operand.

is_not(other)

Perform a logical "is not" comparison with the given operand.

len()

Return the length of the current object as a reactive expression.

map(func, /, *args, **kwargs)

Apply a function to each item in the reactive collection.

not_()

Perform a logical NOT operation on the current reactive value.

or_(other)

Perform a logical OR operation with the given operand.

pipe(func, /, *args, **kwargs)

Apply a chainable function to the current reactive value.

resolve([nested, recursive])

Resolve references held by the reactive expression.

set(value)

Set the input of the pipeline to a new value.

updating()

Return a new expression that indicates whether the current expression is updating.

watch([fn, onlychanged, queued, precedence])

Add a callback to observe changes in the reactive expression's output.

when(*dependencies[, initial])

Create a reactive expression that updates only when specified dependencies change.

where(x, y)

Return either x or y depending on the current state of the expression.

Attributes

value

Get or set the current state of the reactive expression.