Cleanse icon indicating copy to clipboard operation
Cleanse copied to clipboard

Add support for swift concurrency

Open BrentMifsud opened this issue 2 years ago • 2 comments

With Swift 6 on the horizon, this library is going become quite painful to use.

Already today I am facing tons of actor isolation related compiler errors.

Are there any plans to address this?

for example:

image

BrentMifsud avatar Oct 17 '23 22:10 BrentMifsud

Until this is solved, a work around is to mark the init as nonisolated.

This should be ok for viewmodel as you would not expect to do anything that would require mainactor and if you did you could always create a task to run on the main actor.

The rest of the method on the viewmodel will still be protected by the main actor and called form SwiftUi view, which automatically run the body function in main actor isolation.

edys avatar Jan 24 '24 21:01 edys

这是来自QQ邮箱的自动回复邮件。   邮件已收到

majie776 avatar Jan 24 '24 21:01 majie776

Until this is solved, a work around is to mark the init as nonisolated.

This should be ok for viewmodel as you would not expect to do anything that would require mainactor and if you did you could always create a task to run on the main actor.

The rest of the method on the viewmodel will still be protected by the main actor and called form SwiftUi view, which automatically run the body function in main actor isolation.

This wouldn't work if you were working with an observable object for example.

You might want to compute the initial values of your published properties in the init which wouldn't be possible to do in a nonisolated context.

BrentMifsud avatar Mar 18 '24 17:03 BrentMifsud

Cleanse is now deprecated. Please read the deprecation notice on the README for next steps. Thank you!

brianwang9100 avatar Jun 13 '24 18:06 brianwang9100