Files
OAuthSwift/Sources/Handler/OAuthSwiftURLHandlerProxy.swift
phimage e14ac9cbff Move each url handler to its own file
Add a factory to choose default one
Add to iOS demo app the `ASWebAuthentifcationURLHandler`
2019-11-01 22:36:13 +01:00

28 lines
673 B
Swift

//
// OAuthSwiftURLHandlerProxy.swift
// OAuthSwift
//
// Created by phimage on 01/11/2019.
// Copyright © 2019 Dongri Jin, Marchand Eric. All rights reserved.
//
import Foundation
/// Proxy class to make weak reference to handler.
open class OAuthSwiftURLHandlerProxy: OAuthSwiftURLHandlerType {
weak var proxiable: OAuthSwiftURLHandlerType?
public init(_ proxiable: OAuthSwiftURLHandlerType) {
self.proxiable = proxiable
}
open func handle(_ url: URL) {
proxiable?.handle(url)
}
}
extension OAuthSwiftURLHandlerType {
public func weak() -> OAuthSwiftURLHandlerType {
return OAuthSwiftURLHandlerProxy(self)
}
}