diff --git a/Examples/Counter/Counter/Counter.swift b/Examples/Counter/Counter/Counter.swift index e38762a..af99124 100644 --- a/Examples/Counter/Counter/Counter.swift +++ b/Examples/Counter/Counter/Counter.swift @@ -16,8 +16,8 @@ struct Counter: Dripper { // MARK: Nested Types - @MainActor @Observable + @MainActor final class State: Sendable { var counter: Int = .zero var text = "" @@ -43,11 +43,6 @@ struct Counter: Dripper { state.counter = .zero case .randomNumber: return .run { pour in - func randomNumber() async throws -> Int { - try await Task.sleep(for: .seconds(1)) - return Int.random(in: 1...100) - } - let randomNumber = try await randomNumber() pour(.decreaseCounter) @@ -58,6 +53,13 @@ struct Counter: Dripper { return .none } } + + // MARK: Functions + + private func randomNumber() async throws -> Int { + try await Task.sleep(for: .seconds(1)) + return Int.random(in: 1...100) + } } import SwiftUI diff --git a/Sources/Dripper/Effect.swift b/Sources/Dripper/Effect.swift index b968919..e239202 100644 --- a/Sources/Dripper/Effect.swift +++ b/Sources/Dripper/Effect.swift @@ -50,8 +50,8 @@ extension Effect { // MARK: Static Functions public static func run( - blend: @escaping (_ pour: Pour) async throws -> Void, - catch errorHandler: ((_ error: any Error, _ pour: Pour) async -> Void)? = nil, + blend: @escaping @MainActor (_ pour: Pour) async throws -> Void, + catch errorHandler: (@MainActor (_ error: any Error, _ pour: Pour) async -> Void)? = nil, fileID: StaticString = #fileID, line: UInt = #line ) -> Self {