-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stack Interface #5
Comments
@fjbelchi , lets talk about the protocol. Some ideas: // Determines if the saving has to be done after each saving request or when the app goes to the bakground.
enum SavingType {
case .instantSaving, .globalSaving,
}
// Instance Variables
var model: NSManagedObjectModel
var storeCoordinator: NSPersistentStoreCoordinator
var savingType: SavingType
var logLevel: SugarRecordLogger
// Instance methods
func save(#asynchronously: Bool, (context: NSManagedObjectContext) -> ()))
func perform(#asynchronously: Bool, (context: NSManagedObjectContext) -> ()))
func description() -> String // Returns information about the stack
func cleanUp()
// Class Variables
static var defaultStack: SugarRecordStack This should be at first the language SugarRecord should know to communicate with them @fjbelchi . Let's take a look and give some ideas!. Once we have it defined we can split the implementation and work separately. |
I'm still thinking and playing with playground to have a better a idea how the stack could fit well. This is my initial idea, but not completed obviously: protocol CoreDataStack {
var name: String { get }
var stackDescription: String { get }
var model: NSManagedObjectModel { get }
var persistanceStoreCoordinator: NSPersistentStoreCoordinator { get }
var persistanceStore : [NSPersistentStore] { get }
init(stackName:String)
} I will keep investigating and adding more protocols :) |
@fjbelchi persistantStore is an Array? |
I think having persistantStore as an array can be flexible for architecture where it might be need it. In most of the scenario for simple apps you typically use only 1 persitantStore.. let's keep thinking about that, there are more pieces to complete the puzzle |
Mmm I see but I think this is something internal to the stack that SugarRecord shouldn't know about @fjbelchi . One more thing, what about the communication of SR with the stack?, methods that stacks should implement? |
Step by step, still testing.. what's your though? protocol SugarRecordStack : SugarRecordSave {
var name: String { get }
var stackDescription: String { get }
var model: NSManagedObjectModel { get }
var persistanceStoreCoordinator: NSPersistentStoreCoordinator { get }
var persistanceStore : [NSPersistentStore] { get }
init(stackName:String)
}
protocol SugarRecordSave {
func save() -> (Bool, NSError?)
func save(completion: (Bool, NSError?) -> ())
}
protocol SugarRecordTable : SugarRecordSave {
typealias object
init(stack: SugarRecordStack)
} |
What's the SugarRecordTable for? @fjbelchi |
Still thinking how to add the objects, more tweaks: class SugarRecord {
let db : SugarRecordStack
init(stack:SugarRecordStack) {
self.db = stack;
}
// -- Perhaps this should be a factory for the stacks
}
protocol SugarRecordStack : SugarRecordSave {
var name: String { get }
var stackDescription: String { get }
init(stackName:String)
}
protocol CoreDataStack : SugarRecordStack {
var model: NSManagedObjectModel { get }
var persistanceStoreCoordinator: NSPersistentStoreCoordinator { get }
var persistanceStore : [NSPersistentStore] { get }
}
protocol SugarRecordSave {
func save() -> (Bool, NSError?)
func save(completion: (Bool, NSError?) -> ())
}
protocol CoreDataSave : SugarRecordSave {
func save(context:NSManagedObjectContext) -> (Bool, NSError?)
func save(context:NSManagedObjectContext, completion: (Bool, NSError?) -> ())
}
protocol SugarRecordTable : SugarRecordSave {
typealias object
init(stack: SugarRecordStack)
}
// SugarRecord.db.save() |
Working on it here #18 |
Offer a protocol and implementations to let a consumer implement its own custom stack.
The text was updated successfully, but these errors were encountered: