Compare commits

..

No commits in common. "master" and "fix/execute" have entirely different histories.

5 changed files with 2 additions and 38 deletions

View File

@ -1 +1 @@
binary "https://raw.github.com/TouchInstinct/CarthageBinaries/master/RxSwift/RxSwift.json"
github "ReactiveX/RxSwift" ~> 4.3

View File

@ -1 +1 @@
binary "https://raw.github.com/TouchInstinct/CarthageBinaries/master/RxSwift/RxSwift.json" "4.5.0"
github "ReactiveX/RxSwift" "4.4.0"

View File

@ -13,8 +13,6 @@ import WebKit
/**
*/
public class ReCaptcha {
public typealias BoolParameterClosure = (Bool) -> ()
fileprivate struct Constants {
struct InfoDictKeys {
static let APIKey = "ReCaptchaKey"
@ -103,12 +101,6 @@ public class ReCaptcha {
}
}
/// Callback for WebView loading state changing
public var onLoadingChanged: BoolParameterClosure? {
get { return manager.onLoadingChanged }
set { manager.onLoadingChanged = newValue }
}
/// The worker that handles webview events and communication
let manager: ReCaptchaWebViewManager

View File

@ -44,9 +44,6 @@ internal class ReCaptchaWebViewManager {
public var shouldSkipForTests = false
#endif
/// Callback for loading state changing
var onLoadingChanged: ReCaptcha.BoolParameterClosure?
/// Sends the result message
var completion: ((ReCaptchaResult) -> Void)?
@ -109,7 +106,6 @@ internal class ReCaptchaWebViewManager {
*/
init(html: String, apiKey: String, baseURL: URL, endpoint: String) {
self.endpoint = endpoint
self.decoder = ReCaptchaDecoder { [weak self] result in
self?.handle(result: result)
}
@ -137,7 +133,6 @@ internal class ReCaptchaWebViewManager {
Starts the challenge validation
*/
func validate(on view: UIView) {
onLoadingChanged?(true)
#if DEBUG
guard !shouldSkipForTests else {
completion?(.token(""))
@ -199,7 +194,6 @@ fileprivate extension ReCaptchaWebViewManager {
webView.evaluateJavaScript(Constants.NumberOfDivsCommand) { [weak self] (result, error) -> Void in
if let error = error {
self?.decoder.send(error: .unexpected(error))
self?.onLoadingChanged?(false)
} else {
self?.handleNumberOfDivs(result: result, count: count)
}
@ -233,7 +227,6 @@ fileprivate extension ReCaptchaWebViewManager {
}
} else {
decoder.send(error: .htmlLoadError)
onLoadingChanged?(false)
}
}
@ -245,7 +238,6 @@ fileprivate extension ReCaptchaWebViewManager {
if let error = error {
self?.decoder.send(error: .unexpected(error))
}
self?.onLoadingChanged?(false)
}
}

View File

@ -9,10 +9,6 @@
import RxSwift
import UIKit
public enum ReCaptchaRxError: Error {
case baseWasReleased
}
/// Makes ReCaptcha compatible with RxSwift extensions
extension ReCaptcha: ReactiveCompatible {}
@ -68,20 +64,4 @@ public extension Reactive where Base: ReCaptcha {
base?.reset()
}
}
/**
Observable of loading state
(will not work if someone changes onLoadingChanged variable; current onLodinglChanged will not work after subscription)
*/
var loadingObservable: Observable<Bool> {
return .create { [weak base] observer -> Disposable in
guard let base = base else {
observer.onError(ReCaptchaRxError.baseWasReleased)
return Disposables.create()
}
base.onLoadingChanged = { observer.onNext($0) }
return Disposables.create { [weak base] in base?.onLoadingChanged = nil }
}
}
}