WIP: StorageInterface protocol

This commit is contained in:
John Rommel Estropia
2016-03-03 07:50:43 +09:00
parent 99189d160f
commit ad1ebb3501
17 changed files with 214 additions and 261 deletions

View File

@@ -15,10 +15,12 @@ private struct Static {
static let timeZonesStack: DataStack = {
let dataStack = DataStack()
try! dataStack.addSQLiteStoreAndWait(
fileName: "TimeZoneDemo.sqlite",
configuration: "FetchingAndQueryingDemo",
resetStoreOnModelMismatch: true
try! dataStack.addStorageAndWait(
SQLiteStore(
fileName: "TimeZoneDemo.sqlite",
configuration: "FetchingAndQueryingDemo",
resetStoreOnModelMismatch: true
)
)
dataStack.beginSynchronous { (transaction) -> Void in

View File

@@ -49,10 +49,12 @@ private struct Static {
static let palettes: ListMonitor<Palette> = {
try! CoreStore.addSQLiteStoreAndWait(
fileName: "ColorsDemo.sqlite",
configuration: "ObservingDemo",
resetStoreOnModelMismatch: true
try! CoreStore.addStorageAndWait(
SQLiteStore(
fileName: "ColorsDemo.sqlite",
configuration: "ObservingDemo",
resetStoreOnModelMismatch: true
)
)
return CoreStore.monitorSectionedList(

View File

@@ -30,7 +30,7 @@ class CustomLoggerViewController: UIViewController, CoreStoreLogger {
super.viewDidLoad()
try! self.dataStack.addSQLiteStoreAndWait(fileName: "emptyStore.sqlite")
try! self.dataStack.addStorageAndWait(SQLiteStore(fileName: "emptyStore.sqlite"))
CoreStore.logger = self
}
@@ -109,11 +109,12 @@ class CustomLoggerViewController: UIViewController, CoreStoreLogger {
}
case .Some(1):
do {
try self.dataStack.addSQLiteStoreAndWait(fileName: "emptyStore.sqlite", configuration: "invalidStore")
}
catch _ { }
_ = try? dataStack.addStorageAndWait(
SQLiteStore(
fileName: "emptyStore.sqlite",
configuration: "invalidStore"
)
)
case .Some(2):
self.dataStack.beginAsynchronous { (transaction) -> Void in

View File

@@ -18,15 +18,19 @@ private struct Static {
static let facebookStack: DataStack = {
let dataStack = DataStack(modelName: "StackSetupDemo")
try! dataStack.addSQLiteStoreAndWait(
fileName: "AccountsDemo_FB_Male.sqlite",
configuration: maleConfiguration,
resetStoreOnModelMismatch: true
try! dataStack.addStorageAndWait(
SQLiteStore(
fileName: "AccountsDemo_FB_Male.sqlite",
configuration: maleConfiguration,
resetStoreOnModelMismatch: true
)
)
try! dataStack.addSQLiteStoreAndWait(
fileName: "AccountsDemo_FB_Female.sqlite",
configuration: femaleConfiguration,
resetStoreOnModelMismatch: true
try! dataStack.addStorageAndWait(
SQLiteStore(
fileName: "AccountsDemo_FB_Female.sqlite",
configuration: femaleConfiguration,
resetStoreOnModelMismatch: true
)
)
dataStack.beginSynchronous { (transaction) -> Void in
@@ -52,15 +56,19 @@ private struct Static {
static let twitterStack: DataStack = {
let dataStack = DataStack(modelName: "StackSetupDemo")
try! dataStack.addSQLiteStoreAndWait(
fileName: "AccountsDemo_TW_Male.sqlite",
configuration: maleConfiguration,
resetStoreOnModelMismatch: true
try! dataStack.addStorageAndWait(
SQLiteStore(
fileName: "AccountsDemo_TW_Male.sqlite",
configuration: maleConfiguration,
resetStoreOnModelMismatch: true
)
)
try! dataStack.addSQLiteStoreAndWait(
fileName: "AccountsDemo_TW_Female.sqlite",
configuration: femaleConfiguration,
resetStoreOnModelMismatch: true
try! dataStack.addStorageAndWait(
SQLiteStore(
fileName: "AccountsDemo_TW_Female.sqlite",
configuration: femaleConfiguration,
resetStoreOnModelMismatch: true
)
)
dataStack.beginSynchronous { (transaction) -> Void in

View File

@@ -18,10 +18,12 @@ private struct Static {
static let placeController: ObjectMonitor<Place> = {
try! CoreStore.addSQLiteStoreAndWait(
fileName: "PlaceDemo.sqlite",
configuration: "TransactionsDemo",
resetStoreOnModelMismatch: true
try! CoreStore.addStorageAndWait(
SQLiteStore(
fileName: "PlaceDemo.sqlite",
configuration: "TransactionsDemo",
resetStoreOnModelMismatch: true
)
)
var place = CoreStore.fetchOne(From(Place))