Files
yingmeng-ios-switf/yinmeng-ios/HttpRequest/YMPluginSubType.swift
2024-02-21 21:30:13 +08:00

74 lines
2.9 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// YMPluginSubType.swift
// yinmeng-ios
//
// Created by MaiMang on 2024/2/2.
//
import Foundation
import Moya
public protocol PluginPropertiesable: PluginSubType {
var plugins: APIPlugins { get set }
var key: String? { get set }
/// Loading HUD delay hide time.
var delay: Double { get }
}
extension PluginPropertiesable {
public var delay: Double {
return 0
}
}
/// Moya便
/// Inherit the Moya plug-in protocol, which is convenient for subsequent expansion. All plug-in methods must implement this protocol
public protocol PluginSubType: Moya.PluginType {
///
var pluginName: String { get }
///
///
/// - Parameters:
/// - request:
/// - target:
/// - Returns:
///
/// After setting the network configuration information, before starting to prepare the request,
/// This method can be used in scenarios such as throwing data directly when the local cache exists without executing subsequent network requests.
/// - Parameters:
/// - request: Configuration information, which contains the data source and whether to end the subsequent network request.
/// - target: The protocol used to define the specifications necessary for a `MoyaProvider`.
/// - Returns: Containing the data source and whether to end the subsequent network request.
func configuration(_ request: HeadstreamRequest, target: TargetType) -> HeadstreamRequest
///
///
/// - Parameters:
/// - result:
/// - target:
/// - onNext:
///
/// The last time the last network response is returned,
/// This method can be used in scenarios such as key invalidation to obtain the key again and then automatically request the network again.
/// - Parameters:
/// - result: Containing the data source and whether auto-last network request.
/// - target: The protocol used to define the specifications necessary for a `MoyaProvider`.
/// - onNext: Provide callbacks for the plug-in to process tasks asynchronously.
func lastNever(_ result: LastNeverResult, target: TargetType, onNext: @escaping LastNeverCallback)
}
extension PluginSubType {
public func configuration(_ request: HeadstreamRequest, target: TargetType) -> HeadstreamRequest {
return request
}
public func lastNever(_ result: LastNeverResult, target: TargetType, onNext: @escaping LastNeverCallback) {
onNext(result)
}
}