Skip to content

Instantly share code, notes, and snippets.

@ivangodfather
Created December 19, 2017 14:19
Show Gist options
  • Save ivangodfather/a295078a41e3fb75531203ea55ccae14 to your computer and use it in GitHub Desktop.
Save ivangodfather/a295078a41e3fb75531203ea55ccae14 to your computer and use it in GitHub Desktop.
public class MyMoyaProvider<Target>: MoyaProvider<Target> where Target: Moya.TargetType {
override init(endpointClosure: @escaping EndpointClosure = MoyaProvider.defaultEndpointMapping,
requestClosure: @escaping RequestClosure = MoyaProvider.defaultRequestMapping,
stubClosure: @escaping StubClosure = MoyaProvider.neverStub,
callbackQueue: DispatchQueue? = nil,
manager: Manager = MoyaProvider<Target>.defaultAlamofireManager(),
plugins: [PluginType] = [],
trackInflights: Bool = false) {
super.init(endpointClosure: endpointClosure,
requestClosure: requestClosure,
stubClosure: stubClosure,
callbackQueue: callbackQueue,
manager: manager,
plugins: plugins,
trackInflights: trackInflights)
}
public override func request(_ target: Target, callbackQueue: DispatchQueue?, progress: ProgressBlock?, completion: @escaping Completion) -> Cancellable {
return super.request(target, callbackQueue: callbackQueue, progress: progress, completion: completion)
//Basically here i would like to be able to flatMap the Response and if statusCode == 401 perform a refresh token, or maybe using retryWhen
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment