param.reactive.reactive_ops.generation#

property reactive_ops.generation: int#

The generation of this node’s current value.

Changes whenever the node takes a new value, even without running its operation, and not when the operation raises Skip.

Inside the node’s own operation it is the generation the value being computed will have. Stamp it beside what the operation writes to .rx.meta; a stamp that no longer matches means the metadata does not describe the current value. An operation that raises after writing produces a ReactiveError with a matching stamp, so also ignore metadata when the value is a ReactiveError.

>>> import param
>>> def produce(v):
...     node = param.current_node()
...     node.rx.meta['trace'] = {'v': v, 'generation': node.rx.generation}
...     return v * 10
>>> expr = param.rx(1).rx.pipe(produce)
>>> expr.rx.value
10
>>> expr.rx.meta['trace']['generation'] == expr.rx.generation
True

A superseded asynchronous run may write a stamp that matches the generation of the run replacing it.

Returns:

The node’s generation.

Return type:

int