MCMirrorAbstraction
public protocol MCMirrorAbstraction: AnyObject, MCArrayComparer
This protocol enables conforming types to give access to an array of Recordable, and to match array’s contents to the cloud.
-
Receivers can only work with one type (for error handling).
Declaration
Swift
associatedtype type: MCRecordable
-
This read-only, computed property returns unique string identifier for the receiver.
Declaration
Swift
var name: String
-
changeNotification
Default implementationThis read-only, computed property returns the Notificaion.Name that will be posted anytime silentRecordables is updated. This notification does not trigger any activity internal to Magic Cloud, but allows apps implementing the framework to know when receivers have been updated, both from the cloud and locally.
Default Implementation
Defaults to a Notification.Name constructed from MCMirrorAbstraction.name property.
Declaration
Swift
var changeNotification: Notification.Name
-
This read-only, computed property returns a serial dispatch queue for local changes to recordables.
Declaration
Swift
var serialQ: DispatchQueue
-
This read-only property stores the cloud database being mirrored.
Declaration
Swift
var db: MCDatabase
-
Changes made to this array will NOT be reflected to the cloud and NOT broadcast to other local receivers. Can still be observed using
changeNotification
property.Declaration
Swift
var silentRecordables: [type]
-
localRecordables
Default implementationChanges made to this array will NOT be reflected to the cloud and WILL broadcast to other local receivers.
Default Implementation
Defaults to a computed property to get
silentRecordables
& setnewValue
to aLocalChangePackage
that is broadcast throughNotificationCenter.default
(observe byrecordType
name) and set tosilentRecordables
.Declaration
Swift
var localRecordables: [type]
-
cloudRecordables
Default implementationChanges made to this array WILL be reflected to the cloud and WILL broadcast to other local receivers.
Default Implementation
Defaults to a computed property to get
silentRecordables
& setnewValue
to cloud database (which will trigger set forlocalRecordables
.Declaration
Swift
var cloudRecordables: [type]
-
This property stores the CKQuerySubscription used by the receiver and should not be modified.
Declaration
Swift
var subscription: MCSubscriber
-
subscribeToChanges(on:)
Default implementationThis method subscribes to changes from the specified database, and prepares handling of events. Any changes that are detected will be reflected in recordables array.
Implementation for this method should not be overwritten.
Default Implementation
This method subscribes to changes from the specified database, and prepares handling of events. Any changes that are detected will be reflected in recordables array. Implementation for this method should not be overwritten.
Declaration
Swift
func subscribeToChanges(on: MCDatabase)
Parameters
on
An argument representing the database that receiver receives recordables from.
-
unsubscribeToChanges()
Default implementationThis method unsubscribes from previous subscription. Implementation for this method should not be overwritten.
Default Implementation
This method unsubscribes from previous subscription. Implementation for this method should not be overwritten.
Declaration
Swift
func unsubscribeToChanges()
-
downloadAll(from:completion:)
Default implementationThis method empties recordables, and refills it from the specified database. Implementation for this method should not be overwritten.
Default Implementation
This method empties recordables, and refills it from the specified database. Implementation for this method should not be overwritten.
Declaration
Swift
func downloadAll(from: MCDatabase, completion: OptionalClosure)
Parameters
from
An argument representing the database that receiver receives recordables from.
completion
If not nil, a closure that will be executed upon completion (no passed args).