Skip to content

Instantly share code, notes, and snippets.

View raonivaladares's full-sized avatar

Raoni Valadares raonivaladares

View GitHub Profile
func execute(with urlRquest: URLRequest) -> AnyPublisher<Data, NetworkPlataformError> {
return urlSession
.dataTaskPublisher(for: urlRquest)
.tryMap { data, response in
if let error = URLResponseErrorParser().parseErrorIfExists(on: response) {
throw error
}
return data
}
func execute(
with urlRquest: URLRequest,
completion: @escaping (Result<Data, NetworkPlataformError>) -> Void) {
urlSession.dataTask(with: urlRquest) { data, urlResponse, error in
if let error = error {
let errorParsed = NetworkPlataformErrorParser().parse(error)
completion(.failure(errorParsed))
return
}
func sum<T: Numeric>(x: T, y: T) -> T {
return x + y
}
enum Result<Value> {
case success(Value)
case failure(Error)
}
import UIKit
extension UIFont {
enum FontStyle {
case bold
case book
case light
case regular
}
private let topicLabel = UILabelFactory(text: "Topic 1")
.fontSize(of: 36)
.build()
private let subTopicLabel = UILabelFactory(text: "subTopic")
.build()
private let profileImageView = UIImageViewFactory(image: UIImage(named: "UserProfilePlaceHolder"))
.build()
import UIKit
final class UIButtonFactory {
private let button: UIButton
enum Style {
case normal
case especial
}
import UIKit
final class UILabelFactory {
private let label: UILabel
private let defultFontSize: CGFloat = 20
// MARK: - Inits
init(text: String) {
label = UILabel()
label.textAlignment = .center
final class UILabelFactory {
private let label: UILabel
private let defultFontSize: CGFloat = 20
// MARK: - Inits
init(text: String) {
label = UILabel()
label.textAlignment = .center
label.text = text
label.font = label.font.withSize(defultFontSize)
private let topicLabel: UILabel = {
let label = UILabel()
label.text = "Topic"
label.textAlignment = .center //textAlignment count = 1
label.font = label.font.withSize(36)
label.translatesAutoresizingMaskIntoConstraints = false //translatesAutoresizingMaskIntoConstraints count = 1
return label
}()