Last active
January 14, 2023 14:02
-
-
Save ricardopsantos/8e2b43606632888306f693a8dd508d2e to your computer and use it in GitHub Desktop.
Article_13_G3.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typealias ResponseWithCacheMaybe = AnyPublisher<ResponseDto.EmployeeServiceAvailability, AppErrors> | |
/// No cache API call | |
public func requestWithoutCache(param: String) -> ResponseWithCacheMaybe { | |
let requestDto = FRPSampleAPI.RequestDto.Employee(someParam: param) | |
let apiRequest = sampleRepository2.requestSampleJSON(requestDto) | |
return apiRequest.mapError({$0.toAppError}).eraseToAnyPublisher() | |
} | |
/// - parameter cachePolicy: chacheNoLoad || noCacheDoLoad || cacheElseLoad || cacheAndLoad | |
public func requestWithCacheMaybe(param: String, | |
cachePolicy: CachePolicy) -> ResponseWithCacheMaybe { | |
let apiRequest = requestWithoutCache(param: param) | |
let serviceKey = #function | |
let serviceParams: [String] = [param] | |
let apiResponseType = ResponseDto.EmployeeServiceAvailability.self | |
return NetworkinNameSpace.NetworkingUtils.genericRequestWithCache(apiRequest, | |
apiResponseType, | |
cachePolicy, | |
serviceKey, | |
serviceParams) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment