param.reactive.rx#
- class param.reactive.rx(obj=None, **kwargs)[source]#
A class for creating reactive expressions by wrapping objects.
The
rxclass allows you to wrap objects and operate on them interactively, recording any operations applied. These recorded operations form a pipeline that can be replayed dynamically when an operand changes. This makesrxparticularly useful for building reactive workflows, such as real-time data processing or dynamic user interfaces.- Parameters:
obj (any) – The object to wrap, such as a number, string, list, or any supported data structure.
References
For more details, see the user guide: https://param.holoviz.org/user_guide/Reactive_Expressions.html
Examples
Instantiate
rxfrom an object:>>> from param import rx >>> reactive_float = rx(3.14)
Perform operations on the reactive object:
>>> reactive_result = reactive_float * 2 >>> reactive_result.value 6.28
Update the original value and see the updated result:
>>> reactive_float.value = 1 >>> reactive_result.rx.value 2
Create a reactive list and compute its length reactively:
>>> reactive_list = rx([1, 2, 3]) >>> reactive_length = reactive_list.rx.len() >>> reactive_length.rx.value 3
- __init__(obj=None, operation=None, fn=None, depth=0, method=None, prev=None, _shared_obj=None, _current=None, _wrapper=None, **kwargs)[source]#
Methods
__init__([obj, operation, fn, depth, ...])register_accessor(name, accessor[, predicate])Register an accessor that extends
rxwith custom behavior.register_display_handler(obj_type, handler, ...)Register a display handler for a specific type of object.
register_method_handler(method, handler)Register a handler that is called when a specific method on an object is called.
Attributes
rxThe reactive operations namespace.