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
extension PriceAlert { | |
static func sample( | |
id: String = "42", | |
symbol: String = "AAPL", | |
targetPrice: MoneyItem = MoneyItem(amount: 1050, currency: "USD"), | |
createdAt: Date = Date(timeIntervalSince1970: 1526202500) | |
) -> PriceAlert { | |
return PriceAlert( | |
id: id, | |
symbol: symbol, |
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
struct PriceAlert: Equatable { | |
let id: String | |
let symbol: String | |
let targetPrice: MoneyItem | |
let createdAt: Date | |
} | |
// test | |
let priceAlert = PriceAlert( |
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
import Foundation | |
public struct MockFunc<Input, Output> { | |
public var parameters: [Input] = [] | |
public var result: (Input) -> Output = { _ in fatalError() } | |
public init() {} | |
public init(result: @escaping (Input) -> Output) { | |
self.result = result |
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
<html class="gr__storage_googleapis_com gr__00e9e64bacf7b26af0ec62b69a505d4303b0a5655b10ba2c05-apidata_googleusercontent_com"><head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link href="risk_warning_files/css.html" rel="stylesheet" type="text/css"> | |
<title>Risk warning</title> | |
<style> | |
body { | |
background-color: #ffffff; |
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
import UIKit | |
import Foundation | |
final class MessageSender { | |
private let api: API = TestAPI() | |
func send(images: [UIImage], text: String, completion: @escaping () -> Void) { | |
// TODO: please implement this method | |
} |
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
enum Result<T> { | |
case failure(Error) | |
case success(T) | |
} | |
let requestQueue = DispatchQueue(label: "RequestQueue", qos: .background) | |
/// Mock request that waits for 0.5 seconds and then call the completion block | |
/// | |
/// - Parameter completion: the block of code to execute for the request |
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 fetchUserId() -> Future<Int> { | |
return Future { promise in | |
var request = URLRequest(url: URL(string: "http://facebook.com/me")) | |
URLSession.shared.dataTask(with: request) { data, response, error in | |
if let data = data { | |
promise.resolve(Int(data)) | |
} else if error = error { | |
promise.reject(error) | |
} | |
}.resume() |
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
struct Promise<Value> { | |
let closure: (Result<Value, Error>) -> Void | |
func resolve(_ value: Value) { | |
closure(.success(value)) | |
} | |
func reject(_ error: Error) { | |
closure(.failure(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
enum Result<Value, Error> { | |
case success(Value) | |
case failure(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
func fetchUserId(completion: @escaping (Int?, Error?) -> Void) { | |
let request = URLRequest(url: URL(string: "http://facebook.com/me")) | |
URLSession.shared.dataTask(with: request) { data, response, error in | |
if let data = data { | |
completion(Int(data), nil) | |
} else if error = error { | |
completion(nil, error) | |
} | |
}.resume() | |
} |