param.reactive.reactive_ops.upstream#

reactive_ops.upstream() → Iterator[rx][source]#

Iterate over the rx nodes this expression derives its value from, directly or transitively, excluding itself. Pipeline edges count: .rx.pipe/operator chaining, a branch (expr[0]), an rx passed as an operation argument, and an rx reached through a Parameter(allow_refs=True). An input masked by .rx.overrides, including the one chained from, is replaced by its override. A dependency reached only through bind(), .rx.when, or .rx.where is not included.

Traversal order is unspecified and may change between calls as the pipeline is extended. Do not use in on the iterator to test membership: rx.__eq__ builds a comparison expression rather than a bool, so x in upstream() is not a reliable membership test. Use x in set(upstream()) instead.

Returns:

Empty if the .rx namespace does not belong to an rx node.

Return type:

Iterator[rx]

Examples

>>> import param
>>> a = param.rx(1)
>>> b = a.rx.pipe(lambda x, y: x + y, y=param.rx(2))
>>> a in set(b.rx.upstream())
True