-
Hello, I’m wondering if the following logic (modified from the cheatsheet) is possible: @state.change("var_name", "var_name_1")
def change_detected(**kwargs):
print(f"{state_name} is modified to {state_name_value}") My goal is to use a single @state.change decorator to identify which field triggered the callback. While it’s certainly possible to use individual decorators for each state, this becomes cumbersome with a large amount of state values which need the same action (printing change or calling a function). A single decorator for this use case would be ideal. Thank you in advance for any help and apologies if I have overlooked a past discussion of similar question. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
This is something that I'm also missing. It would be great to have something like |
Beta Was this translation helpful? Give feedback.
-
Yes you should be able to do @state.change(*VAR_NAMES)
def change_detected(**_):
modified_names = [n for n in VAR_NAMES if state.is_dirty(n)]
print(f"Triggerd because {modified_names} changed")
for n in modified_names:
print(f"{n} = {state[n]}") |
Beta Was this translation helpful? Give feedback.
Fixed with
trame-server>=3.3
with the following example.