Skip to content

Commit 30114bd

Browse files
committed
fix duplicated RxWKNavigationDelegateProxy in RxSwift and RxWebKit
1 parent 4f70b83 commit 30114bd

File tree

4 files changed

+12
-65
lines changed

4 files changed

+12
-65
lines changed

RxWebKit.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
C4878CD61FA1066C00B12C60 /* FailedRequestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4878CD51FA1066C00B12C60 /* FailedRequestViewController.swift */; };
3535
C4878CD81FA117E900B12C60 /* RedirectViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4878CD71FA117E900B12C60 /* RedirectViewController.swift */; };
3636
C4878CDA1FA11B5A00B12C60 /* OtherRequestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4878CD91FA11B5A00B12C60 /* OtherRequestViewController.swift */; };
37-
C48E617E1F9E27A700C6A753 /* RxWKNavigationDelegateProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48E617D1F9E27A700C6A753 /* RxWKNavigationDelegateProxy.swift */; };
3837
C48E61841F9E336000C6A753 /* WKNavigationDelegateEvents+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48E61831F9E336000C6A753 /* WKNavigationDelegateEvents+Rx.swift */; };
3938
C4CA6B07228AB1680088A7A3 /* ForwardsEventsBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4CA6B06228AB1680088A7A3 /* ForwardsEventsBehavior.swift */; };
4039
EFC27F84246D7E9C0093D8B3 /* RxWebKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4CB7D5322874EE700FB8D99 /* RxWebKitTests.swift */; };
@@ -148,7 +147,6 @@
148147
C4878CD51FA1066C00B12C60 /* FailedRequestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FailedRequestViewController.swift; sourceTree = "<group>"; };
149148
C4878CD71FA117E900B12C60 /* RedirectViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RedirectViewController.swift; sourceTree = "<group>"; };
150149
C4878CD91FA11B5A00B12C60 /* OtherRequestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OtherRequestViewController.swift; sourceTree = "<group>"; };
151-
C48E617D1F9E27A700C6A753 /* RxWKNavigationDelegateProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RxWKNavigationDelegateProxy.swift; sourceTree = "<group>"; };
152150
C48E61831F9E336000C6A753 /* WKNavigationDelegateEvents+Rx.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WKNavigationDelegateEvents+Rx.swift"; sourceTree = "<group>"; };
153151
C4A50F9E229AF3EF0037E608 /* config.yml */ = {isa = PBXFileReference; lastKnownFileType = text; name = config.yml; path = .circleci/config.yml; sourceTree = SOURCE_ROOT; };
154152
C4CA6B06228AB1680088A7A3 /* ForwardsEventsBehavior.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForwardsEventsBehavior.swift; sourceTree = "<group>"; };
@@ -211,7 +209,6 @@
211209
children = (
212210
42F426DB1C662CF9001FED46 /* Rx+WebKit.swift */,
213211
C48E61831F9E336000C6A753 /* WKNavigationDelegateEvents+Rx.swift */,
214-
C48E617D1F9E27A700C6A753 /* RxWKNavigationDelegateProxy.swift */,
215212
C4607FCF1FA0DAC9002DA12F /* RxWKUIDelegateProxy.swift */,
216213
C4607FD51FA0DC40002DA12F /* RxWKUIDelegateEvents+Rx.swift */,
217214
F6D7DD0C224F62860066C90F /* RxWKUserContentController.swift */,
@@ -514,7 +511,6 @@
514511
files = (
515512
42F426DC1C662CF9001FED46 /* Rx+WebKit.swift in Sources */,
516513
C48E61841F9E336000C6A753 /* WKNavigationDelegateEvents+Rx.swift in Sources */,
517-
C48E617E1F9E27A700C6A753 /* RxWKNavigationDelegateProxy.swift in Sources */,
518514
C4607FD01FA0DAC9002DA12F /* RxWKUIDelegateProxy.swift in Sources */,
519515
F6D7DD0D224F62860066C90F /* RxWKUserContentController.swift in Sources */,
520516
C4607FD61FA0DC40002DA12F /* RxWKUIDelegateEvents+Rx.swift in Sources */,

RxWebKitTests/ForwardsEventsBehavior.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ForwardsEventsBehavior: Quick.Behavior<ForwardsEventsBehaviorContext> {
4747
describe("Has Events Behavior") {
4848
it("sentMessage") {
4949
SharingScheduler.mock(scheduler: scheduler) {
50-
let sentMessage = scheduler.record(source: sut.rx.delegate.sentMessage(selector))
50+
let sentMessage = scheduler.record(source: sut.rx.navigationDelegate.sentMessage(selector))
5151
invoked()
5252
scheduler.start()
5353
expect(sentMessage.events.count).to(equal(1))
@@ -56,7 +56,7 @@ class ForwardsEventsBehavior: Quick.Behavior<ForwardsEventsBehaviorContext> {
5656

5757
it("methodInvoke") {
5858
SharingScheduler.mock(scheduler: scheduler) {
59-
let methodInvoked = scheduler.record(source: sut.rx.delegate.methodInvoked(selector))
59+
let methodInvoked = scheduler.record(source: sut.rx.navigationDelegate.methodInvoked(selector))
6060
invoked()
6161
scheduler.start()
6262
expect(methodInvoked.events.count).to(equal(1))

Sources/RxWebKit/RxWKNavigationDelegateProxy.swift

Lines changed: 0 additions & 44 deletions
This file was deleted.

Sources/RxWebKit/WKNavigationDelegateEvents+Rx.swift

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,9 @@ extension Reactive where Base: WKWebView {
4343
/// WKNavigationActionPolicyEvent emits a tuple event of WKWebView + WKNavigationAction + ActionHandler
4444
public typealias WKNavigationActionPolicyEvent = ( webView: WKWebView, action: WKNavigationAction, handler: ActionHandler)
4545

46-
/// Reactive wrapper for `navigationDelegate`.
47-
public var delegate: DelegateProxy<WKWebView, WKNavigationDelegate> {
48-
return RxWKNavigationDelegateProxy.proxy(for: base)
49-
}
50-
5146
/// Reactive wrapper for delegate method `webView(_ webView: WKWebView, didCommit navigation: WKNavigation!)`.
5247
public var didCommitNavigation: ControlEvent<WKNavigationEvent> {
53-
let source: Observable<WKNavigationEvent> = delegate
48+
let source: Observable<WKNavigationEvent> = navigationDelegate
5449
.methodInvoked(.didCommitNavigation)
5550
.map { arg in
5651
let view = try castOrThrow(WKWebView.self, arg[0])
@@ -62,7 +57,7 @@ extension Reactive where Base: WKWebView {
6257

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

7570
/// Reactive wrapper for delegate method `webView(_ webView: WKWebView, didFinish navigation: WKNavigation!)`
7671
public var didFinishNavigation: ControlEvent<WKNavigationEvent> {
77-
let source: Observable<WKNavigationEvent> = delegate
72+
let source: Observable<WKNavigationEvent> = navigationDelegate
7873
.methodInvoked(.didFinishNavigation)
7974
.map { arg in
8075
let view = try castOrThrow(WKWebView.self, arg[0])
@@ -87,15 +82,15 @@ extension Reactive where Base: WKWebView {
8782
/// Reactive wrapper for delegate method `webViewWebContentProcessDidTerminate(_ webView: WKWebView)`.
8883
@available(iOS 9.0, *)
8984
public var didTerminate: ControlEvent<WKWebView> {
90-
let source: Observable<WKWebView> = delegate
85+
let source: Observable<WKWebView> = navigationDelegate
9186
.methodInvoked(.didTerminate)
9287
.map { try castOrThrow(WKWebView.self, $0[0]) }
9388
return ControlEvent(events: source)
9489
}
9590

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

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

121116
/// Reactive wrapper for delegate method `webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error)`.
122117
public var didFailProvisionalNavigation: ControlEvent<WKNavigationFailEvent> {
123-
let source: Observable<WKNavigationFailEvent> = delegate
118+
let source: Observable<WKNavigationFailEvent> = navigationDelegate
124119
.methodInvoked(.didFailProvisionalNavigation)
125120
.map { arg in
126121
let view = try castOrThrow(WKWebView.self, arg[0])
@@ -148,7 +143,7 @@ extension Reactive where Base: WKWebView {
148143
credential.
149144
@discussion If you do not implement this method, the web view will respond to the authentication challenge with the NSURLSessionAuthChallengeRejectProtectionSpace disposition.
150145
*/
151-
let source: Observable<WKNavigationChallengeEvent> = delegate
146+
let source: Observable<WKNavigationChallengeEvent> = navigationDelegate
152147
.sentMessage(.didReceiveChallenge)
153148
.map { arg in
154149
/// Extracting the WKWebView from the array at index zero
@@ -205,7 +200,7 @@ extension Reactive where Base: WKWebView {
205200
/// Reactive wrapper for `func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Swift.Void)`
206201
public var decidePolicyNavigationResponse: ControlEvent<WKNavigationResponsePolicyEvent> {
207202
typealias __DecisionHandler = @convention(block) (WKNavigationResponsePolicy) -> ()
208-
let source:Observable<WKNavigationResponsePolicyEvent> = delegate
203+
let source:Observable<WKNavigationResponsePolicyEvent> = navigationDelegate
209204
.methodInvoked(.decidePolicyNavigationResponse).map { args in
210205
let view = try castOrThrow(WKWebView.self, args[0])
211206
let response = try castOrThrow(WKNavigationResponse.self, args[1])
@@ -225,7 +220,7 @@ extension Reactive where Base: WKWebView {
225220
/// Reactive wrapper for `func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Swift.Void)`
226221
public var decidePolicyNavigationAction: ControlEvent<WKNavigationActionPolicyEvent> {
227222
typealias __ActionHandler = @convention(block) (WKNavigationActionPolicy) -> ()
228-
let source:Observable<WKNavigationActionPolicyEvent> = delegate
223+
let source:Observable<WKNavigationActionPolicyEvent> = navigationDelegate
229224
.methodInvoked(.decidePolicyNavigationAction).map { args in
230225
let view = try castOrThrow(WKWebView.self, args[0])
231226
let action = try castOrThrow(WKNavigationAction.self, args[1])

0 commit comments

Comments
 (0)