fluxa/appleApp/AppleCore/FluxaApplePlatformEffectExecutor.swift
2026-07-13 15:50:42 +03:00

22 lines
750 B
Swift

import Foundation
protocol FluxaApplePlatformEffectHandler: AnyObject {
func execute(effect: FluxaAppleHeadlessEffect) async throws -> FluxaAppleJsonValue
}
final class FluxaApplePlatformEffectExecutor: FluxaAppleHeadlessEffectExecutor {
private let handler: any FluxaApplePlatformEffectHandler
init(handler: any FluxaApplePlatformEffectHandler) {
self.handler = handler
}
func execute(effect: FluxaAppleHeadlessEffect) async -> FluxaAppleHeadlessCompletion {
do {
return .success(effectId: effect.id, value: try await handler.execute(effect: effect))
} catch {
let code = (error as NSError).domain
return .failure(effectId: effect.id, code: code)
}
}
}