observe should take @isolated(any) functions#306
Conversation
| @_inheritActorContext _ apply: @escaping @isolated(any) @Sendable () -> Void | ||
| ) -> ObserveToken { | ||
| observe(isolation: isolation) { _ in apply() } | ||
| observe { _ in Result(catching: apply).get() } |
There was a problem hiding this comment.
This is a trick similarly employed by the Observations type to convert an @isolated(any) to a synchronous function. I'm not sure if there is a more legit way to assume the isolation of a closure to perform it synchronously.
There was a problem hiding this comment.
I'm fixing conflicts for #286 and looks like this implementation gives a bunch of warnings on Xcode 26 beta 4 🤔
Converting
@isolated(any)function of type'@isolated(any) @Sendable (UITransaction) -> Void'to synchronous function type'@Sendable (UITransaction) -> Void'is not allowed; this will be an error in a future Swift language mode 🤔
There was a problem hiding this comment.
@maximkrouk These warnings are fine. They even exist in Swift's Observation framework. Luckily they don't show up downstream.
The current signatures were the result of fighting language changes in real time, and while it mostly worked in a non-default main actor world, I think this is more correct.