Simplify asynchronous/long running callbacks #2288
Labels
💬 Discussion
Requires some discussion and decision
🖰 GUI
Related to GUI
📈 Improvement
Improvement of a feature.
🟧 Priority: High
Must be addressed as soon
Description
Use Case:
Developers must use asynchronous callbacks to keep the client responsive (if callbacks take a long time to execute). This is an important concept for advanced use cases.
Current Challenges:
Currently, developers must rely on
invoke_callback
andinvoke_long_callback
. These functions are complex and require some knowledge to use:invoke_callback
requires:gui
state_id
(which requires understanding and usingget_state_id()
)callback
invoke_long_callback
requires:state
user_function
user_function_args
user_status_function
user_status_function_args
period
(to specify how often the status function updates)By itself, this API is not the simplest. This is somehow related to: Avaiga/taipy-doc#888
Although
invoke_long_callback
includes aperiod
property for periodic updates, this does not provide real-time feedback on the progress of the heavy function. To achieve this, developers must implement additional logic, frequently invokinginvoke_callback
to update the state manually, as shown in the following example:This approach results in verbose, repetitive, and complex code.
Proposed Improvement:
The goal is to simplify the process for both:
The ideal solution would follow standard Taipy practices and avoid introducing overly complex concepts.
Initial Proposition:
Introduce an
AsyncState
class that mimics the behavior of a standardState
but is designed for asynchronous operations. This simplifies the process for developers while maintaining flexibility.Implementation:
AsyncState
and Helper Functions:Developer Code:
Benefits of the Proposed Solution:
Acceptance Criteria
Code of Conduct
The text was updated successfully, but these errors were encountered: