Skip to content

Conversation

@alexandre-pod
Copy link

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.

Using.Task.immediate.creation.mov
Using.Task.creation.mov

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.

@Dean151 Dean151 self-assigned this Nov 12, 2025
@Dean151 Dean151 added the enhancement New feature or request label Nov 12, 2025
@Dean151
Copy link
Owner

Dean151 commented Nov 27, 2025

Does it build against older Swift versions?
If I am to build this with 6.1, will I encounter a build error as it's a language feature as well?

@alexandre-pod
Copy link
Author

Does it build against older Swift versions? If I am to build this with 6.1, will I encounter a build error as it's a language feature as well?

I haven't thought about that, and you are right when using a Swift version below 6.2 it fails to compile with the error: Type 'Task<Success, Failure>' has no member 'immediate'.
I have pushed a fix that only use the new Task.immediate API when building with 6.2.

@alexandre-pod
Copy link
Author

With the latest commit I was able to build and run the demo app using Xcode 16.2.0 that is using Swift 6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants