This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol URLRequestable { | |
func load(urlRequest: URLRequest) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LegacyWebView: UIView, URLRequestable { | |
private var webView: UIWebView! | |
func load(urlRequest: URLRequest) { | |
webView.loadRequest(urlRequest) | |
} | |
// other code here | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConsumerViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let webView = createWebView(usingModern: true) | |
// add webView to the view hierachy | |
if let urlRequestable = webView as? URLRequestable { | |
urlRequestable.load(urlRequest: URLRequest(url: URL(string: "www.google.it")!)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"plugins": [ ["transform-remove-console", { "exclude": [ "error" ] }] ] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"plugins": ["transform-remove-console"] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yarn install --dev babel-plugin-transform-remove-console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "MyBrownfieldApp", | |
"version": "0.0.1", | |
"private": true, | |
"scripts": { | |
"start": "node node_modules/react-native/local-cli/cli.js start" | |
}, | |
"dependencies": { | |
"react": "16.3.1", | |
"react-native": "0.55" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) { | |
guard let response = navigationResponse.response as? HTTPURLResponse, | |
let url = navigationResponse.response.url else { | |
decisionHandler(.cancel) | |
return | |
} | |
if let headerFields = response.allHeaderFields as? [String: String] { | |
let cookies = HTTPCookie.cookies(withResponseHeaderFields: headerFields, for: url) | |
cookies.forEach { cookie in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
precedencegroup CustomPrecedenceGroup { | |
associativity: left | |
} | |
infix operator |> : CustomPrecedenceGroup | |
func |> (value: Int, f: (Int) -> Int) -> Int { | |
return f(value) | |
} |