PCKSynchronizable

public protocol PCKSynchronizable

Objects that conform to the PCKSynchronizable protocol are synchronized between the OCKStore and the Parse Cloud. In order to synchronize objects, they must also conform to either PCKObjectable or PCKVersionable. For examples, see PCKPatient, PCKCarePlan, PCKTask, PCKContact, and PCKOutcome.

  • Adds an object that conforms to PCKSynchronizable to the Parse Server and keeps it synchronized with the CareKitStore.

    Declaration

    Swift

    func addToCloud(completion: @escaping (Result<PCKSynchronizable, Error>) -> Void)

    Parameters

    completion

    The block to execute. It should have the following argument signature: (Result<PCKSynchronizable,Error>).

  • Updates an object that conforms to PCKSynchronizable that is already on the Parse Server and keeps it synchronized with the CareKitStore.

    Declaration

    Swift

    func updateCloud(completion: @escaping (Result<PCKSynchronizable, Error>) -> Void)

    Parameters

    overwriteRemote

    Whether data should be overwritten if it’s already present on the Parse Server.

    completion

    The block to execute. It should have the following argument signature: (Result<PCKSynchronizable,Error>).

  • Creates a new ParseCareKit object from a specified CareKit entity.

    Declaration

    Swift

    func new(with careKitEntity: OCKEntity) throws -> Self

    Parameters

    with

    The CareKit entity used to create the new ParseCareKit object.

    Return Value

    Returns a new version of Self

  • Fetch all objects from the server that have been made on since the last time synchronization was performed.

    Warning

    The mergeRevision closure should never be called in parallel. Wait until one merge has completed before starting another.

    Declaration

    Swift

    func pullRevisions(since localClock: Int,
                       cloudClock: OCKRevisionRecord.KnowledgeVector,
                       remoteID: String,
                       mergeRevision: @escaping (Result<OCKRevisionRecord, ParseError>) -> Void)

    Parameters

    since

    The last time a synchronization was performed locally

    cloudClock

    The server clock represented as a vector.

    mergeRevision

    A closure that can be called multiple times to merge revisions.

  • Push a revision from a device up to the server.

    Declaration

    Swift

    func pushRevision(cloudClock: Int,
                      remoteID: String,
                      completion: @escaping (Error?) -> Void)

    Parameters

    cloudClock

    The current clock value of the revision.

    completion

    A closure that should be called once the push completes.