Skip to content

Instantly share code, notes, and snippets.

@robertvunabandi
Created November 18, 2025 05:07
Show Gist options
  • Select an option

  • Save robertvunabandi/527ac0a1c8ba8295ba2006741b95e2a6 to your computer and use it in GitHub Desktop.

Select an option

Save robertvunabandi/527ac0a1c8ba8295ba2006741b95e2a6 to your computer and use it in GitHub Desktop.
//
// DataType.swift
// Reading Journal
//
//
import Foundation
enum DataType: CaseIterable {
case beta
/// `authors` is for ``MAuthor`` models.
case authors
case feedback
case sources
case sourceSections
case quotes
case search
static func flushAll() {
LOG.info("Flushing all DataStores", #line)
allCases.forEach { $0.storeType().flush() }
}
private func storeType() -> any DataStore.Type {
let type = getStoreType()
assert(
type.Enum == self,
"type.Enum (\(type.Enum)) doesn't match .getStoreType() (\(type))"
)
return type
}
private func getStoreType() -> any DataStore.Type {
switch self {
case .authors:
AuthorsDataStore.self
case .beta:
BetaDataStore.self
case .feedback:
FeedbackDataStore.self
case .sources:
SourcesDataStore.self
case .sourceSections:
SourceSectionsDataStore.self
case .quotes:
QuotesDataStore.self
case .search:
SearchDataStore.self
}
}
private static let LOG = Tools.getLogger(filename: #file)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment