async API prototypes

This commit is contained in:
John Estropia
2022-07-10 10:39:45 +09:00
parent e9219682b5
commit da4ac192db
6 changed files with 581 additions and 104 deletions

View File

@@ -49,7 +49,7 @@ extension DataStack {
// MARK: Publisher
public typealias Output = MigrationProgress
public typealias Output = CoreStore.MigrationProgress<Storage>
public typealias Failure = CoreStoreError
public func receive<S: Subscriber>(subscriber: S) where S.Input == Output, S.Failure == Failure {
@@ -63,56 +63,6 @@ extension DataStack {
)
}
// MARK: - MigrationProgress
/**
A `MigrationProgress` contains info on a `LocalStorage`'s setup progress.
- SeeAlso: DataStack.reactive.addStorage(_:)
*/
public enum MigrationProgress {
/**
The `LocalStorage` is currently being migrated
*/
case migrating(storage: Storage, progressObject: Progress)
/**
The `LocalStorage` has been added to the `DataStack` and is ready for reading and writing
*/
case finished(storage: Storage, migrationRequired: Bool)
/**
The fraction of the overall work completed by the migration. Returns a value between 0.0 and 1.0, inclusive.
*/
public var fractionCompleted: Double {
switch self {
case .migrating(_, let progressObject):
return progressObject.fractionCompleted
case .finished:
return 1
}
}
/**
Returns `true` if the storage was successfully added to the stack, `false` otherwise.
*/
public var isCompleted: Bool {
switch self {
case .migrating:
return false
case .finished:
return true
}
}
}
// MARK: - AddStorageSubscriber
@@ -232,6 +182,12 @@ extension DataStack {
private let storage: Storage
private var subscriber: S?
}
// MARK: Deprecated
@available(*, deprecated, renamed: "MigrationProgress")
public typealias MigrationProgress = CoreStore.MigrationProgress<Storage>
}
}