PersistenceIntegration

public protocol PersistenceIntegration : Integration

Conform to this protocol and initialize your Client instance with the persistenceIntegration initialization parameter set to recieve messages about creation and deletion of Entrys and Assets in your space when doing sync operations using the Client.initialSync() and Client.nextSync()methods. Proper conformance to this protocol should enable persisting the state changes that happen in your Contentful space to a persistent store such asCoreData`.

  • Updates the PersistenceIntegration with information about the locales supported in the current space.

    Declaration

    Swift

    func update(localeCodes: [LocaleCode])
  • Updates the local datastore with the latest delta messages from the most recently fetched SyncSpace response.

    There is no guarantee which thread this will be called from, so it is your responsibility when implementing this method, to execute on whatever thread your local datastore may require operations to be executed on.

    Declaration

    Swift

    func update(with syncSpace: SyncSpace)
  • This is called whenever a new Asset was created or an existing one was updated.

    There is no guarantee which thread this will be called from, so it is your responsibility when implementing this method, to execute on whatever thread your local datastore may require operations to be executed on.

    Declaration

    Swift

    func create(asset: Asset)

    Parameters

    asset

    he created/updated Asset.

  • This is called whenever an asset was deleted.

    There is no guarantee which thread this will be called from, so it is your responsibility when implementing this method, to execute on whatever thread your local datastore may require operations to be executed on.

    Declaration

    Swift

    func delete(assetWithId: String)

    Parameters

    assetId

    Identifier of the asset that was deleted.

  • This is called whenever a new entry was created or an existing one was updated.

    There is no guarantee which thread this will be called from, so it is your responsibility when implementing this method, to execute on whatever thread your local datastore may require operations to be executed on.

    Declaration

    Swift

    func create(entry: Entry)

    Parameters

    entry

    The created/updated Entry.

  • This is called whenever an entry was deleted before the next sync.

    There is no guarantee which thread this will be called from, so it is your responsibility when implementing this method, to execute on whatever thread your local datastore may require operations to be executed on.

    Declaration

    Swift

    func delete(entryWithId: String)

    Parameters

    entryId

    Identifier of the entry that was deleted.

  • This method is called on completion of a successful sync call on a Client instance. calls so that the sync token can be cached and future launches of your application can synchronize without doing an sync.

    There is no guarantee which thread this will be called from, so it is your responsibility when implementing this method, to execute on whatever thread your local datastore may require operations to be executed on.

    Declaration

    Swift

    func update(syncToken: String)

    Parameters

    syncToken

    The string sync token that should be cached to that subsequent sync’s pickup at the right spot.

  • This method is called after all Entrys have been created and all links have been resolved. The implementation should map Entry fields that are Links to persistent relationships in the underlying persistent data store. There is no guarantee which thread this will be called from, so it is your responsibility when implementing this method, to execute on whatever thread your local datastore may require operations to be executed on.

    Declaration

    Swift

    func resolveRelationships()
  • This method is called after all assets and entries have been tranformed to persistable data structures. The implementation should actually perform the save operation to the persisent database.

    There is no guarantee which thread this will be called from, so it is your responsibility when implementing this method, to execute on whatever thread your local datastore may require operations to be executed on.

    Declaration

    Swift

    func save()