Consider adding context manager support for use with e.g. `rx()`
- Dominant language
- Python
- Stars
- 521
- Forks
- 86
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 35
Description
### Is your feature request related to a problem? Please describe.
I recently came across this library and really liked the `rx()` example shown in README.md. I do not like having to invoke e.g. `val1.rx.value` to query and set the value of this node. I thought perhaps an (optional extra) context manager could be used to help separate defining each node / graph to reduce the amount of boilerplate needed when these values would be used.
#### Describe the solution you'd like
Here is an example showing what I am talking about here (naming TBD, not adapted to the existing `param` ecosystem).
```py
from param import rx
from xxx import BuildParameters
with BuildParameters() as p:
p.r = rx(1.5)
# Inside the block, p.r is the rx node, so this creates a reactive link
p.diameter = p.r * 2
# --- OUTSIDE THE BLOCK ---
# We can update it purely (without .rx.value)
p.r = 2.0
# The graph updated silently, and we can read the pure result
print(f"New Diameter: {p.diameter}")
# Output: New Diameter: 4.0
```
#### Additional context
I have a working implementation of this, not sharing yet as I wanted to gauge interest in the overall idea first.
Contributor guide
Assessment
This issue has not been assessed yet.