You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of change #236 , you must now provide lambdas that accept the event positional argument. However, we should allow you to pass in a function that doesn't accept any positional arguments without crashing as well. E.g. this snippet should work:
importdeephaven.uiasuifromdeephaven.uiimportuse_state@ui.componentdefcounter():
count, set_count=use_state(0)
return [
# Pass in a function that accepts the event argumentui.action_button(f"Foo {count}", on_press=lambdae: set_count(count+1)),
# Pass in a function that does not have any positional argumentsui.action_button(f"Bar {count}", on_press=lambda: set_count(count+1))
]
c=counter()
The text was updated successfully, but these errors were encountered:
Fixes#260
This snippet now works:
```
import deephaven.ui as ui
from deephaven.ui import use_state
@ui.component
def counter():
count, set_count = use_state(0)
return [
# Pass in a function that accepts the event argument
ui.action_button(f"Foo {count}", on_press=lambda e: set_count(count + 1)),
# Pass in a function that does not have any positional arguments
ui.action_button(f"Bar {count}", on_press=lambda: set_count(count + 1))
]
c = counter()
```
This implementation is more robust than that though. It supports:
1. Dropping any number of positional args. For example, if the callback
supports 3 positional args but only two are defined, the third will be
not be passed in.
3. Dropping any unused keyword args.
4. If `*args` or `**kwargs` are used, all of the relevant args are
passed in.
As of change #236 , you must now provide lambdas that accept the event positional argument. However, we should allow you to pass in a function that doesn't accept any positional arguments without crashing as well. E.g. this snippet should work:
The text was updated successfully, but these errors were encountered: