Skip to content

Demonstrating MainActor issues on Swift 5.7 with strict concurrency enabled

License

Notifications You must be signed in to change notification settings

dannys42/MainActorWoes

Repository files navigation

MainActorWoes

This package demonstrates some challenges in accessing MainActor bound properties. For example purposes, I'm using UIUserInterfaceIdiom, but it be any property that is @MainActor bound.

  • Example01 - shows how the naive approach forces @MainActor onto all intializers, which is not something we always want or can do.

  • Example02 - simply demonstrates that MainActor isolation is a compile time failure when struct concurrency checking is enabled

  • Example03 - demonstrates a one approach in not requiring @MainActor for the initializer. It has the unfortunate side-effect of requiring not being on the main thread.

  • MainActorWoesTests - demonstrates how these examples might look at the call-site and in unit tests.

About

Demonstrating MainActor issues on Swift 5.7 with strict concurrency enabled

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages