RxSwiftCommunity / RxWebKit

RxWebKit is a RxSwift wrapper for WebKit
MIT License
249 stars 104 forks source link

Support for WebKit's delegtes #10

Closed cojoj closed 7 years ago

cojoj commented 7 years ago

Right now RxWebKit supports only properties taken directly from WKWebView. When I started playing around more extensively with WebKit I started missing stuff from WKNavigationDelegate and WKUIDelegate. Is there any specific reason why RxWebKit doesn't implement proxies for those delegates, or is it only because you didn't need them? I'd love to see official implementation for those proxy delegates 😉 If you're willing to add them I'd be happy to implement them! Just let me know 🙌

freak4pc commented 7 years ago

Hey @cojoj , If you feel something is missing feel free to push a PR ! I'll help review.

cojoj commented 7 years ago

Haha, it's not that simple as I thought it'd be...

When I started with WKNavigationDelegate it turned out that there're some methods that need to be implemented, because they have completion, so they expect some default values as to work properly. Let's say it's similar to UITableViewDataSource for example. In that case something has has to provide default implementation for those, and of course, I'd be the best to hide them from user and place them in our proxy objects. For example here: https://github.com/ReactiveX/RxSwift/blob/master/RxCocoa/iOS/Proxies/RxPickerViewDataSourceProxy.swift they have something called PickerViewDataSourceNotSet and it's a default implementation for those required methods. I guess in order to make delegates for WKWebView work we need to have something similar since I on every run I get the following crash:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Completion handler passed to -[NSObject webView:decidePolicyForNavigationAction:decisionHandler:] was not called'

It's really strange that WKNavigationDelegate crashes, but WKUIDelegate works fine, even though it's methods also have completion handlers.

bobgodwinx commented 7 years ago

@mokumoku @freak4pc @rynecheow is someone working on this issue? Can I fix? it because I have it working locally already? the delegate closure is a real pain.

rynecheow commented 7 years ago

Can you submit a pull request @bobgodwinx ?

bobgodwinx commented 7 years ago

@rynecheow I saw you were working on it on update/rxswift4 I mean you were on the good path though. I will take it from the branch?

bobgodwinx commented 7 years ago

fixed in #15