Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix conditional use_effect in use_table_listener #422

Merged
merged 3 commits into from
Apr 18, 2024

Conversation

jnumainville
Copy link
Collaborator

fixes #384

Moves the refreshing table check to ensure the use_effect is always called.
Also added a use_effect to use_table_data to ensure that when a table is swapped it updates the resulting data

Here is an example of flipping between ticking and static tables

import deephaven.ui as ui
from deephaven.table import Table
from deephaven import time_table, empty_table

empty_t = empty_table(0)
time_t = time_table("PT1S").tail(1)

@ui.component
def test_component():
    empty, set_empty = ui.use_state(True)
    val = ui.use_table_data(empty_t if empty else time_t)
    button = ui.action_button(str(empty), on_press=lambda: set_empty(not empty))

    return [button, str(val)]

data = test_component()

@jnumainville jnumainville requested a review from mofojed April 18, 2024 19:25
@jnumainville jnumainville merged commit 5f4f238 into deephaven:main Apr 18, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use_table_listener/use_table_data cannot be called on both live and static tables
2 participants