use_table_listener
use_table_listener lets you listen to a table for raw updates. This is an advanced feature requiring an understanding of how table listeners work and the limitations of running code while the Update Graph is running. Most usages of this are more appropriate to implement with table data hooks. This is useful when you want to listen to the raw updates from a table and perform a custom action when the table updates.
Example
Display the last updated row
Here’s an example that listens to table updates and will display the last update as a header above the table. This is a simple example to demonstrate how to use use_table_listener to listen to table updates and update state in your component.
Display a toast
Here is a simple example that listens to table updates and displays a toast message when the table updates. Note you must use a render queue to trigger the toast, as the listener is not fired on the render thread.
API Reference
Listen to a table and call a listener when the table updates. If any dependencies change, the listener will be recreated. In this case, updates may be missed if the table updates while the listener is being recreated.
Returns: None None
| Parameters | Type | Default | Description |
|---|---|---|---|
| table | Table | None | The table to listen to. | |
| listener | Callable[[TableUpdate, bool], None] | TableListener | Either a function or a TableListener with an on_update function. The function must take a TableUpdate and is_replay bool. | |
| dependencies | Tuple[Any] | List[Any] | Dependencies of the listener function, so the hook knows when to recreate the listener | |
| description | str | None | None | An optional description for the UpdatePerformanceTracker to append to the listener’s entry description, default is None. |
| do_replay | bool | False | Whether to replay the initial snapshot of the table, default is False. |