Async/Await: is it possible to start a Task on @MainActor synchronously?

Reviving an old thread again :) Using @kabiroberai 's code above I created this as an example. Tested on Xcode 16.2b3/iOS 18.2 simulator.

Using Task to start the callback processing, you'll notice a quick flicker produced by the fact that Task will hop and startAnimating() and stopAnimating() will get called in different main queue layout passes, even though minimal, it's enough to see them for a frame.

Using Task.startOnMainActor I can avoid the loadingIndicator flickers, since by the time we check the status of isLoading, even though callback is async, if it didn't actually suspend, isLoading is going to be false, so I can avoid calling startAnimating() entirely.

AFAIK there is no way to get this behavior in Swift without some sort of context being passed into callback where the API client can signal "hey, start a loader because I'll do some async work". This becomes automatic based on runtime signals on whether the callback suspended.

Not even reasync can help here, since to invoke the reasync call, we'll need to start a new Task which will hop.

Is there any chance startOnMainActor can be made public API?