-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Return callables from callables in Deephaven UI (#540)
Fixes #322. Will be required for full completion of #321. Currently a little hard to test, but this should demonstrate it if you watch the JS debug logs on `WidgetHandler`. Run this Python code. - The `Normal` button should behave the same as latest dh.ui. - The `Nested` button will return a callable as the direct result of the callback function. This should allow us to do `const fn = await callable(args);` basically. It is not called, but there is a log from `WidgetHandler` after 5-10s that it was cleaned up. Or you can use the `Memory` tab in dev tools and click the broom icon to trigger a manual GC. - The `Double Nested` button will return and wrap an object containing a new callable. You can filter the browser logs for `WidgetUtils` and look for `callable ID result string` which won't have the parsed function, but will contain the object representing it as well as the other parts of the returned object. - The `Not serializable` button will basically do nothing except log an error in the Python console. The returned result will include that it was a serialization error to JS, but we do nothing with it. ```py from deephaven import ui @ui.component def my_comp(): on_press = ui.use_callback(lambda d: print(d), []) on_press_nested = ui.use_callback(lambda: print, []) on_press_double_nested = ui.use_callback(lambda: { "nestedFn": print, "some_val": 4 }, []) on_press_unserializable = ui.use_callback(lambda: set([1, 2, 3]), []) return [ ui.button("Normal", on_press=on_press), ui.button("Nested", on_press=on_press_nested), ui.button("Double Nested", on_press=on_press_double_nested), ui.button("Not Serializable", on_press=on_press_unserializable) ] c = my_comp() ```
- Loading branch information
1 parent
c8845b6
commit 8322c2d
Showing
5 changed files
with
279 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.