diff --git a/param/reactive.py b/param/reactive.py index cf38bca4..a972d2fe 100644 --- a/param/reactive.py +++ b/param/reactive.py @@ -556,10 +556,10 @@ def __init__( self._method = method self._operation = operation self._depth = depth - self._dirty = True + self._dirty = _current is None self._dirty_obj = False self._error_state = None - self._current_ = None + self._current_ = _current if isinstance(obj, rx) and not prev: self._prev = obj else: diff --git a/tests/testreactive.py b/tests/testreactive.py index 40f345e7..0e747684 100644 --- a/tests/testreactive.py +++ b/tests/testreactive.py @@ -314,3 +314,14 @@ def test_reactive_set_value_non_root_raises(): rx_val = rx(1) + 1 with pytest.raises(AttributeError): rx_val.rx.value = 3 + +def test_reactive_clone_evaluates_once(): + namex = rx('bob') + + items = [] + def debug(value): + items.append(value) + return value + + assert namex.rx.pipe(debug).title().rx.value == 'Bob' + assert len(items) == 1