Skip to content

Commit

Permalink
minor API fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Usbergo committed Jun 28, 2020
1 parent e24a948 commit 0617b42
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Sources/Store/concurrency/Executor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public final class Executor {
transactions: [AnyTransaction],
handler: TransactionCompletion = nil
) {
let error = AnyError()
let error = ErrorStorage()
var completionOperation: Operation?
if let completionHandler = handler {
/// Wraps the completion handler in an operation.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Store/serialization/Signpost.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public final class SignpostTransaction: AnyTransaction {

public let id: String = PushID.default.make()
public let strategy: Executor.Strategy = .async(nil)
public var error: AnyError? = nil
public var error: ErrorStorage? = nil

/// - note: Never set because `SignpostTransaction`s do not have a backing operation.
public var operation: AsyncOperation {
Expand Down
8 changes: 4 additions & 4 deletions Sources/Store/transactions/Transaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public protocol AnyTransaction: class, Cancellable {
var strategy: Executor.Strategy { get }

/// Tracks any error that might have been raised in this transaction group.
var error: AnyError? { get set }
var error: ErrorStorage? { get set }

/// Represents the transaction execution progress.
/// Trackable `@Published` property.
Expand Down Expand Up @@ -93,7 +93,7 @@ public final class Transaction<A: Action>: AnyTransaction, Identifiable {
public var actionId: String { action.id }
public let id: String = PushID.default.make()
public var strategy = Executor.Strategy.async(nil)
public var error: AnyError?
public var error: ErrorStorage?
public var opaqueStoreRef: AnyStore? {
set {
guard let newValue = newValue as? A.AssociatedStoreType else { return }
Expand Down Expand Up @@ -154,7 +154,7 @@ public final class Transaction<A: Action>: AnyTransaction, Identifiable {
let context = TransactionContext(
operation: operation,
store: store,
errorRef: error,
errorStorage: error,
transaction: self)
action.reduce(context: context)
}
Expand Down Expand Up @@ -189,7 +189,7 @@ public final class Transaction<A: Action>: AnyTransaction, Identifiable {
let context = TransactionContext(
operation: operation,
store: store,
errorRef: error,
errorStorage: error,
transaction: self)
action.cancel(context: context)
context.reject(error: error.error!)
Expand Down
10 changes: 5 additions & 5 deletions Sources/Store/transactions/TransactionContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public struct TransactionContext<S: ReducibleStore, A: Action> {
/// The target store for this transaction.
public let store: S
/// Error internal storage.
public var errorRef = AnyError()
public var errorStorage = ErrorStorage()
/// Last recorded error in this dispatch group.
public var error: Error? { errorRef.error }
public var error: Error? { errorStorage.error }
/// The current transaction.
public let transaction: Transaction<A>

Expand All @@ -31,7 +31,7 @@ public struct TransactionContext<S: ReducibleStore, A: Action> {

/// Terminates this operation with an error.
public func reject(error: Error) {
self.errorRef.error = error
self.errorStorage.error = error
operation.finish()
}

Expand All @@ -41,8 +41,8 @@ public struct TransactionContext<S: ReducibleStore, A: Action> {
}
}

// MARK: - ErrorRef
// MARK: - errorStorage

public final class AnyError {
public final class ErrorStorage {
public var error: Error?
}

0 comments on commit 0617b42

Please sign in to comment.