ButtonKit icon indicating copy to clipboard operation
ButtonKit copied to clipboard

Use Swift 6.2 Task.immediate for task creation to immediately start action

Open alexandre-pod opened this issue 2 months ago • 0 comments

Swift 6.2 added a new API to create a task: Task.immediate(name:priority:executorpreference:operation:), also described in SE-0472 Starting tasks synchronously from caller context.

Using this new api makes possible to remove the delay between the user gesture and the execution of the action, at least until an asynchronous operation is awaited.

Here what can be observed with this change on the demo project. With Task.immediate we prevent the loader to being shown as the reset button executes its action immediately.

https://github.com/user-attachments/assets/2e225763-1b83-4754-8d60-a4435a70b714

https://github.com/user-attachments/assets/cedad533-703e-455a-93b3-3ac46c814435

Note: As this new API is only available on 26.0 version of various of operating systems, the old behaviour is kept when this API is not available.

alexandre-pod avatar Nov 11 '25 12:11 alexandre-pod