You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
LeStorage/LeStorage/SyncedStorable.swift

38 lines
970 B

//
// SyncedStorable.swift
// LeStorage
//
// Created by Laurent Morvillier on 11/10/2024.
//
import Foundation
public protocol SyncedStorable: Storable {
var lastUpdate: Date { get set }
/// Returns HTTP methods that do not need to pass the token to the request
static func tokenExemptedMethods() -> [HTTPMethod]
/// A method called to retrieve data added by the server on a POST request
/// The method will be called after a POST has succeeded,
/// and will provide a copy of what's on the server
/// Should return true to trigger a write on the collection, or false if nothing changed
func copyFromServerInstance(_ instance: any Storable) -> Bool
}
public protocol SideStorable {
var storeId: String? { get set }
}
extension SyncedStorable {
func getStoreId() -> String? {
if let alt = self as? SideStorable {
return alt.storeId
}
return nil
}
}