ExtendedTask

Supervise an extended, long-running task

reactive.ExtendedTask

reactive.ExtendedTask(self, func)

Attributes

Name Description
error Reactive value that tracks the error raised by the task, if the current status is “error”. If the status is not “error”, the value will be unset, and a silent exception will be raised if you try to read it. Calling code should generally not read this value directly, but instead use the result() method, which is designed to behave correctly regardless of the current status.
status Reactive value that tracks the current status of the task. The value will be one of “initial”, “running”, “success”, “error”, or “cancelled”.
value Reactive value that tracks the result of the task, if the current status is “success”. If the status is not “success”, the value will be unset, and a silent exception will be raised if you try to read it. Calling code should generally not read this value directly, but instead use the result() method, which is designed to behave correctly regardless of the current status.

Methods

Name Description
cancel Cancel the current invocation, if any. If there are pending invocations, cancel those too.
invoke Request execution of the slow computation. If there’s already a computation in progress, this will queue up the new invocation to be run after the current one. The arguments to this function are passed to the underlying function.
result Call from a reactive context (e.g. a render function, calc, or effect) to get the result of the computation.

cancel

reactive.ExtendedTask.cancel()

Cancel the current invocation, if any. If there are pending invocations, cancel those too.

invoke

reactive.ExtendedTask.invoke(*args, **kwargs)

Request execution of the slow computation. If there's already a computation in progress, this will queue up the new invocation to be run after the current one. The arguments to this function are passed to the underlying function.

Returns

: None

Immediately returns None. The results of the computation will be available via the result() method.

result

reactive.ExtendedTask.result()

Call from a reactive context (e.g. a render function, calc, or effect) to get the result of the computation.

  • If the computation has finished successfully, the result will be returned.

  • If the computation has finished with an error, the error will be raised.

  • If the computation has never run, or the most recent run was cancelled, a silent exception will be raised that will clear any downstream outputs.

  • If the computation is currently running, a special type of silent exception will be raised that will cause the output to visually reflect that calculation is in progress.

reactive.ExtendedTask.invoke

reactive.ExtendedTask.invoke(*args, **kwargs)

Request execution of the slow computation. If there's already a computation in progress, this will queue up the new invocation to be run after the current one. The arguments to this function are passed to the underlying function.

Returns

: None

Immediately returns None. The results of the computation will be available via the result() method.

reactive.ExtendedTask.result

reactive.ExtendedTask.result()

Call from a reactive context (e.g. a render function, calc, or effect) to get the result of the computation.

  • If the computation has finished successfully, the result will be returned.

  • If the computation has finished with an error, the error will be raised.

  • If the computation has never run, or the most recent run was cancelled, a silent exception will be raised that will clear any downstream outputs.

  • If the computation is currently running, a special type of silent exception will be raised that will cause the output to visually reflect that calculation is in progress.

reactive.ExtendedTask.cancel

reactive.ExtendedTask.cancel()

Cancel the current invocation, if any. If there are pending invocations, cancel those too.