mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-04-18 15:09:47 +02:00
thanks to protocol extensions, you can now omit ListObserver and ObjectObserver methods you don't need to implement
This commit is contained in:
@@ -60,6 +60,19 @@ public protocol ListObserver: class {
|
|||||||
func listMonitorDidChange(monitor: ListMonitor<EntityType>)
|
func listMonitorDidChange(monitor: ListMonitor<EntityType>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public extension ListObserver {
|
||||||
|
|
||||||
|
/**
|
||||||
|
The default implementation does nothing.
|
||||||
|
*/
|
||||||
|
func listMonitorWillChange(monitor: ListMonitor<EntityType>) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
The default implementation does nothing.
|
||||||
|
*/
|
||||||
|
func listMonitorDidChange(monitor: ListMonitor<EntityType>) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: - ListObjectObserver
|
// MARK: - ListObjectObserver
|
||||||
|
|
||||||
@@ -112,6 +125,29 @@ public protocol ListObjectObserver: ListObserver {
|
|||||||
func listMonitor(monitor: ListMonitor<EntityType>, didMoveObject object: EntityType, fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath)
|
func listMonitor(monitor: ListMonitor<EntityType>, didMoveObject object: EntityType, fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public extension ListObjectObserver {
|
||||||
|
|
||||||
|
/**
|
||||||
|
The default implementation does nothing.
|
||||||
|
*/
|
||||||
|
func listMonitor(monitor: ListMonitor<EntityType>, didInsertObject object: EntityType, toIndexPath indexPath: NSIndexPath) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
The default implementation does nothing.
|
||||||
|
*/
|
||||||
|
func listMonitor(monitor: ListMonitor<EntityType>, didDeleteObject object: EntityType, fromIndexPath indexPath: NSIndexPath) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
The default implementation does nothing.
|
||||||
|
*/
|
||||||
|
func listMonitor(monitor: ListMonitor<EntityType>, didUpdateObject object: EntityType, atIndexPath indexPath: NSIndexPath) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
The default implementation does nothing.
|
||||||
|
*/
|
||||||
|
func listMonitor(monitor: ListMonitor<EntityType>, didMoveObject object: EntityType, fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: - ListSectionObserver
|
// MARK: - ListSectionObserver
|
||||||
|
|
||||||
@@ -145,3 +181,16 @@ public protocol ListSectionObserver: ListObjectObserver {
|
|||||||
*/
|
*/
|
||||||
func listMonitor(monitor: ListMonitor<EntityType>, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int)
|
func listMonitor(monitor: ListMonitor<EntityType>, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public extension ListSectionObserver {
|
||||||
|
|
||||||
|
/**
|
||||||
|
The default implementation does nothing.
|
||||||
|
*/
|
||||||
|
func listMonitor(monitor: ListMonitor<EntityType>, didInsertSection sectionInfo: NSFetchedResultsSectionInfo, toSectionIndex sectionIndex: Int) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
The default implementation does nothing.
|
||||||
|
*/
|
||||||
|
func listMonitor(monitor: ListMonitor<EntityType>, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int) { }
|
||||||
|
}
|
||||||
|
|||||||
@@ -67,3 +67,22 @@ public protocol ObjectObserver: class {
|
|||||||
*/
|
*/
|
||||||
func objectMonitor(monitor: ObjectMonitor<EntityType>, didDeleteObject object: EntityType)
|
func objectMonitor(monitor: ObjectMonitor<EntityType>, didDeleteObject object: EntityType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public extension ObjectObserver {
|
||||||
|
|
||||||
|
/**
|
||||||
|
The default implementation does nothing.
|
||||||
|
*/
|
||||||
|
func objectMonitor(monitor: ObjectMonitor<EntityType>, willUpdateObject object: EntityType) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
The default implementation does nothing.
|
||||||
|
*/
|
||||||
|
func objectMonitor(monitor: ObjectMonitor<EntityType>, didUpdateObject object: EntityType, changedPersistentKeys: Set<KeyPath>) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
The default implementation does nothing.
|
||||||
|
*/
|
||||||
|
func objectMonitor(monitor: ObjectMonitor<EntityType>, didDeleteObject object: EntityType) { }
|
||||||
|
}
|
||||||
|
|||||||
@@ -80,11 +80,6 @@ class ObjectObserverDemoViewController: UIViewController, ObjectObserver {
|
|||||||
|
|
||||||
// MARK: ObjectObserver
|
// MARK: ObjectObserver
|
||||||
|
|
||||||
func objectMonitor(monitor: ObjectMonitor<Palette>, willUpdateObject object: Palette) {
|
|
||||||
|
|
||||||
// none
|
|
||||||
}
|
|
||||||
|
|
||||||
func objectMonitor(monitor: ObjectMonitor<Palette>, didUpdateObject object: Palette, changedPersistentKeys: Set<KeyPath>) {
|
func objectMonitor(monitor: ObjectMonitor<Palette>, didUpdateObject object: Palette, changedPersistentKeys: Set<KeyPath>) {
|
||||||
|
|
||||||
self.reloadPaletteInfo(object, changedKeys: changedPersistentKeys)
|
self.reloadPaletteInfo(object, changedKeys: changedPersistentKeys)
|
||||||
|
|||||||
Reference in New Issue
Block a user