diff --git a/Example/AsyncReactorExample.xcodeproj/project.pbxproj b/Example/AsyncReactorExample.xcodeproj/project.pbxproj index 8eff3c2..02ac70e 100644 --- a/Example/AsyncReactorExample.xcodeproj/project.pbxproj +++ b/Example/AsyncReactorExample.xcodeproj/project.pbxproj @@ -380,6 +380,7 @@ SDKROOT = auto; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_STRICT_CONCURRENCY = complete; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -416,6 +417,7 @@ SDKROOT = auto; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_STRICT_CONCURRENCY = complete; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; diff --git a/Example/AsyncReactorExample/Features/Repository/Search/RepositorySearchReactor.swift b/Example/AsyncReactorExample/Features/Repository/Search/RepositorySearchReactor.swift index 38ade6b..7e7bb4f 100644 --- a/Example/AsyncReactorExample/Features/Repository/Search/RepositorySearchReactor.swift +++ b/Example/AsyncReactorExample/Features/Repository/Search/RepositorySearchReactor.swift @@ -51,7 +51,6 @@ class RepositorySearchReactor: AsyncReactor { @Published private(set) var state: State - @MainActor init(state: State = State()) { self.state = state @@ -59,7 +58,7 @@ class RepositorySearchReactor: AsyncReactor { self.handleSortOption(sortBy) lifecycleTask { - for await _ in await NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification).values { + for await _ in NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification).values { await self.action(.load) } @@ -110,7 +109,6 @@ class RepositorySearchReactor: AsyncReactor { } } - @MainActor private func handleSortOption(_ value: String) { state.sortBy = SortOptions(rawValue: value)! } diff --git a/Sources/AsyncReactor/AsyncReactor.swift b/Sources/AsyncReactor/AsyncReactor.swift index cce75fd..7e957b8 100644 --- a/Sources/AsyncReactor/AsyncReactor.swift +++ b/Sources/AsyncReactor/AsyncReactor.swift @@ -7,19 +7,17 @@ import Foundation +@MainActor @dynamicMemberLookup public protocol AsyncReactor: ObservableObject { associatedtype Action associatedtype SyncAction = Never associatedtype State - @MainActor var state: State { get } - @MainActor func action(_ action: Action) async - @MainActor func action(_ action: SyncAction) subscript(dynamicMember keyPath: KeyPath) -> Value { get }