From 0253bbef0d0626ea53c3d4ad24b8f3909cb7c9ed Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Tue, 26 Jul 2022 18:33:52 +0100 Subject: [PATCH] Refactor ServiceProcessor callback --- .../Callbacks/ServiceProcessor.swift | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/Sources/ElixxirDAppsSDK/Callbacks/ServiceProcessor.swift b/Sources/ElixxirDAppsSDK/Callbacks/ServiceProcessor.swift index f6798fa2..e70c4f28 100644 --- a/Sources/ElixxirDAppsSDK/Callbacks/ServiceProcessor.swift +++ b/Sources/ElixxirDAppsSDK/Callbacks/ServiceProcessor.swift @@ -2,20 +2,27 @@ import Bindings import XCTestDynamicOverlay public struct ServiceProcessor { - public typealias Process = ( - _ message: Data, - _ receptionId: Data, - _ ephemeralId: Int64, - _ roundId: Int64 - ) -> Void - - public init(serviceTag: String, process: @escaping Process) { + public struct Callback: Equatable { + public init(message: Data, receptionId: Data, ephemeralId: Int64, roundId: Int64) { + self.message = message + self.receptionId = receptionId + self.ephemeralId = ephemeralId + self.roundId = roundId + } + + public var message: Data + public var receptionId: Data + public var ephemeralId: Int64 + public var roundId: Int64 + } + + public init(serviceTag: String, process: @escaping (Callback) -> Void) { self.serviceTag = serviceTag self.process = process } public var serviceTag: String - public var process: Process + public var process: (Callback) -> Void } extension ServiceProcessor { @@ -41,7 +48,12 @@ extension ServiceProcessor { guard let receptionId = receptionId else { fatalError("BindingsProcessor.process received `nil` receptionId") } - serviceProcessor.process(message, receptionId, ephemeralId, roundId) + serviceProcessor.process(Callback( + message: message, + receptionId: receptionId, + ephemeralId: ephemeralId, + roundId: roundId + )) } func string() -> String { -- GitLab