Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions param/reactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,13 @@ def ternary(condition, _):

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Remember to document :-)

# Operations to get the output and set the input of an expression

def set(self, value):
"""
Sets the input of the pipeline to a new value. Equivalent
to ``.rx.value = value``.
"""
self.value = value

@property
def value(self):
"""
Expand Down
8 changes: 7 additions & 1 deletion tests/testreactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,18 @@ def test_reactive_empty_construct():
i.rx.value = 2
assert i.rx.value == 2

def test_reactive_set_new_value():
def test_reactive_set_new_value_assignment():
i = rx(1)
assert i.rx.value == 1
i.rx.value = 2
assert i.rx.value == 2

def test_reactive_set_new_value_method():
i = rx(1)
assert i.rx.value == 1
i.rx.set(2)
assert i.rx.value == 2

def test_reactive_increment_value():
i = rx(1)
assert i.rx.value == 1
Expand Down