Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix duplicated RxWKNavigationDelegateProxy in RxCocoa and RxWebKit #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions RxWebKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
C4878CD61FA1066C00B12C60 /* FailedRequestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4878CD51FA1066C00B12C60 /* FailedRequestViewController.swift */; };
C4878CD81FA117E900B12C60 /* RedirectViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4878CD71FA117E900B12C60 /* RedirectViewController.swift */; };
C4878CDA1FA11B5A00B12C60 /* OtherRequestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4878CD91FA11B5A00B12C60 /* OtherRequestViewController.swift */; };
C48E617E1F9E27A700C6A753 /* RxWKNavigationDelegateProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48E617D1F9E27A700C6A753 /* RxWKNavigationDelegateProxy.swift */; };
C48E61841F9E336000C6A753 /* WKNavigationDelegateEvents+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48E61831F9E336000C6A753 /* WKNavigationDelegateEvents+Rx.swift */; };
C4CA6B07228AB1680088A7A3 /* ForwardsEventsBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4CA6B06228AB1680088A7A3 /* ForwardsEventsBehavior.swift */; };
EFC27F84246D7E9C0093D8B3 /* RxWebKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4CB7D5322874EE700FB8D99 /* RxWebKitTests.swift */; };
Expand Down Expand Up @@ -148,7 +147,6 @@
C4878CD51FA1066C00B12C60 /* FailedRequestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FailedRequestViewController.swift; sourceTree = "<group>"; };
C4878CD71FA117E900B12C60 /* RedirectViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RedirectViewController.swift; sourceTree = "<group>"; };
C4878CD91FA11B5A00B12C60 /* OtherRequestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OtherRequestViewController.swift; sourceTree = "<group>"; };
C48E617D1F9E27A700C6A753 /* RxWKNavigationDelegateProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RxWKNavigationDelegateProxy.swift; sourceTree = "<group>"; };
C48E61831F9E336000C6A753 /* WKNavigationDelegateEvents+Rx.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WKNavigationDelegateEvents+Rx.swift"; sourceTree = "<group>"; };
C4A50F9E229AF3EF0037E608 /* config.yml */ = {isa = PBXFileReference; lastKnownFileType = text; name = config.yml; path = .circleci/config.yml; sourceTree = SOURCE_ROOT; };
C4CA6B06228AB1680088A7A3 /* ForwardsEventsBehavior.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForwardsEventsBehavior.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -211,7 +209,6 @@
children = (
42F426DB1C662CF9001FED46 /* Rx+WebKit.swift */,
C48E61831F9E336000C6A753 /* WKNavigationDelegateEvents+Rx.swift */,
C48E617D1F9E27A700C6A753 /* RxWKNavigationDelegateProxy.swift */,
C4607FCF1FA0DAC9002DA12F /* RxWKUIDelegateProxy.swift */,
C4607FD51FA0DC40002DA12F /* RxWKUIDelegateEvents+Rx.swift */,
F6D7DD0C224F62860066C90F /* RxWKUserContentController.swift */,
Expand Down Expand Up @@ -514,7 +511,6 @@
files = (
42F426DC1C662CF9001FED46 /* Rx+WebKit.swift in Sources */,
C48E61841F9E336000C6A753 /* WKNavigationDelegateEvents+Rx.swift in Sources */,
C48E617E1F9E27A700C6A753 /* RxWKNavigationDelegateProxy.swift in Sources */,
C4607FD01FA0DAC9002DA12F /* RxWKUIDelegateProxy.swift in Sources */,
F6D7DD0D224F62860066C90F /* RxWKUserContentController.swift in Sources */,
C4607FD61FA0DC40002DA12F /* RxWKUIDelegateEvents+Rx.swift in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions RxWebKitTests/ForwardsEventsBehavior.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ForwardsEventsBehavior: Quick.Behavior<ForwardsEventsBehaviorContext> {
describe("Has Events Behavior") {
it("sentMessage") {
SharingScheduler.mock(scheduler: scheduler) {
let sentMessage = scheduler.record(source: sut.rx.delegate.sentMessage(selector))
let sentMessage = scheduler.record(source: sut.rx.navigationDelegate.sentMessage(selector))
invoked()
scheduler.start()
expect(sentMessage.events.count).to(equal(1))
Expand All @@ -56,7 +56,7 @@ class ForwardsEventsBehavior: Quick.Behavior<ForwardsEventsBehaviorContext> {

it("methodInvoke") {
SharingScheduler.mock(scheduler: scheduler) {
let methodInvoked = scheduler.record(source: sut.rx.delegate.methodInvoked(selector))
let methodInvoked = scheduler.record(source: sut.rx.navigationDelegate.methodInvoked(selector))
invoked()
scheduler.start()
expect(methodInvoked.events.count).to(equal(1))
Expand Down
44 changes: 0 additions & 44 deletions Sources/RxWebKit/RxWKNavigationDelegateProxy.swift

This file was deleted.

25 changes: 10 additions & 15 deletions Sources/RxWebKit/WKNavigationDelegateEvents+Rx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,9 @@ extension Reactive where Base: WKWebView {
/// WKNavigationActionPolicyEvent emits a tuple event of WKWebView + WKNavigationAction + ActionHandler
public typealias WKNavigationActionPolicyEvent = ( webView: WKWebView, action: WKNavigationAction, handler: ActionHandler)

/// Reactive wrapper for `navigationDelegate`.
public var delegate: DelegateProxy<WKWebView, WKNavigationDelegate> {
return RxWKNavigationDelegateProxy.proxy(for: base)
}

/// Reactive wrapper for delegate method `webView(_ webView: WKWebView, didCommit navigation: WKNavigation!)`.
public var didCommitNavigation: ControlEvent<WKNavigationEvent> {
let source: Observable<WKNavigationEvent> = delegate
let source: Observable<WKNavigationEvent> = navigationDelegate
.methodInvoked(.didCommitNavigation)
.map { arg in
let view = try castOrThrow(WKWebView.self, arg[0])
Expand All @@ -62,7 +57,7 @@ extension Reactive where Base: WKWebView {

/// Reactive wrapper for delegate method `webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!)`.
public var didStartProvisionalNavigation: ControlEvent<WKNavigationEvent> {
let source: Observable<WKNavigationEvent> = delegate
let source: Observable<WKNavigationEvent> = navigationDelegate
.methodInvoked(.didStartProvisionalNavigation)
.map { arg in
let view = try castOrThrow(WKWebView.self, arg[0])
Expand All @@ -74,7 +69,7 @@ extension Reactive where Base: WKWebView {

/// Reactive wrapper for delegate method `webView(_ webView: WKWebView, didFinish navigation: WKNavigation!)`
public var didFinishNavigation: ControlEvent<WKNavigationEvent> {
let source: Observable<WKNavigationEvent> = delegate
let source: Observable<WKNavigationEvent> = navigationDelegate
.methodInvoked(.didFinishNavigation)
.map { arg in
let view = try castOrThrow(WKWebView.self, arg[0])
Expand All @@ -87,15 +82,15 @@ extension Reactive where Base: WKWebView {
/// Reactive wrapper for delegate method `webViewWebContentProcessDidTerminate(_ webView: WKWebView)`.
@available(iOS 9.0, *)
public var didTerminate: ControlEvent<WKWebView> {
let source: Observable<WKWebView> = delegate
let source: Observable<WKWebView> = navigationDelegate
.methodInvoked(.didTerminate)
.map { try castOrThrow(WKWebView.self, $0[0]) }
return ControlEvent(events: source)
}

/// Reactive wrapper for delegate method `webView(_ webView: WKWebView, didReceiveServerRedirectForProvisionalNavigation navigation: WKNavigation!)`.
public var didReceiveServerRedirectForProvisionalNavigation: ControlEvent<WKNavigationEvent> {
let source: Observable<WKNavigationEvent> = delegate
let source: Observable<WKNavigationEvent> = navigationDelegate
.methodInvoked(.didReceiveServerRedirectForProvisionalNavigation)
.map { arg in
let view = try castOrThrow(WKWebView.self, arg[0])
Expand All @@ -107,7 +102,7 @@ extension Reactive where Base: WKWebView {

/// Reactive wrapper for delegate method `webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error)`.
public var didFailNavigation: ControlEvent<WKNavigationFailEvent> {
let source: Observable<WKNavigationFailEvent> = delegate
let source: Observable<WKNavigationFailEvent> = navigationDelegate
.methodInvoked(.didFailNavigation)
.map { arg in
let view = try castOrThrow(WKWebView.self, arg[0])
Expand All @@ -120,7 +115,7 @@ extension Reactive where Base: WKWebView {

/// Reactive wrapper for delegate method `webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error)`.
public var didFailProvisionalNavigation: ControlEvent<WKNavigationFailEvent> {
let source: Observable<WKNavigationFailEvent> = delegate
let source: Observable<WKNavigationFailEvent> = navigationDelegate
.methodInvoked(.didFailProvisionalNavigation)
.map { arg in
let view = try castOrThrow(WKWebView.self, arg[0])
Expand Down Expand Up @@ -148,7 +143,7 @@ extension Reactive where Base: WKWebView {
credential.
@discussion If you do not implement this method, the web view will respond to the authentication challenge with the NSURLSessionAuthChallengeRejectProtectionSpace disposition.
*/
let source: Observable<WKNavigationChallengeEvent> = delegate
let source: Observable<WKNavigationChallengeEvent> = navigationDelegate
.sentMessage(.didReceiveChallenge)
.map { arg in
/// Extracting the WKWebView from the array at index zero
Expand Down Expand Up @@ -205,7 +200,7 @@ extension Reactive where Base: WKWebView {
/// Reactive wrapper for `func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Swift.Void)`
public var decidePolicyNavigationResponse: ControlEvent<WKNavigationResponsePolicyEvent> {
typealias __DecisionHandler = @convention(block) (WKNavigationResponsePolicy) -> ()
let source:Observable<WKNavigationResponsePolicyEvent> = delegate
let source:Observable<WKNavigationResponsePolicyEvent> = navigationDelegate
.methodInvoked(.decidePolicyNavigationResponse).map { args in
let view = try castOrThrow(WKWebView.self, args[0])
let response = try castOrThrow(WKNavigationResponse.self, args[1])
Expand All @@ -225,7 +220,7 @@ extension Reactive where Base: WKWebView {
/// Reactive wrapper for `func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Swift.Void)`
public var decidePolicyNavigationAction: ControlEvent<WKNavigationActionPolicyEvent> {
typealias __ActionHandler = @convention(block) (WKNavigationActionPolicy) -> ()
let source:Observable<WKNavigationActionPolicyEvent> = delegate
let source:Observable<WKNavigationActionPolicyEvent> = navigationDelegate
.methodInvoked(.decidePolicyNavigationAction).map { args in
let view = try castOrThrow(WKWebView.self, args[0])
let action = try castOrThrow(WKNavigationAction.self, args[1])
Expand Down