param.reactive.reactive_ops.len#
- reactive_ops.len() rx[source]#
Return the length of the current object as a reactive expression.
Since the
__len__method cannot be overloaded reactively, this method provides a way to compute the length of the current reactive expression. The result is returned as a new reactive expression.- Returns:
A new reactive expression representing the length of the object.
- Return type:
Examples
Compute the length of a reactive list:
>>> import param >>> rx_list = param.rx([1, 2, 3]) >>> rx_len = rx_list.rx.len() >>> rx_len.rx.value 3
Update the reactive list and observe the length update:
>>> rx_list.rx.value = [1, 2, 3, 4, 5] >>> rx_len.rx.value 5
Compute the length of a reactive string:
>>> rx_string = param.rx("Hello World") >>> rx_len = rx_string.rx.len() >>> rx_len.rx.value 11