Skip to content

Instantly share code, notes, and snippets.

View dehrom's full-sized avatar
🤯
creating abstractions

Valery Kokanov dehrom

🤯
creating abstractions
View GitHub Profile
// Copyright © 2019 Ooma Inc. All rights reserved.
import Foundation
import RIBs
import RxSwift
// MARK: - Plugin
public protocol Plugin: AnyObject {
associatedtype Component = Dependency
import Foundation
private let errorDebugDescriptionCreateBlock: (String, ContentRepresentable & IntCodeRepresentable & LocalizedErrorRepresentable) -> String = { name, error in
return """
=== Self is \(name) ===
Code: \(error.code) \r
errorDescription: \(String(describing: error.asLocalizedError?.errorDescription)) \r
failureReason: \(String(describing: error.asLocalizedError?.failureReason)) \r
recoverySuggestion: \(String(describing: error.asLocalizedError?.recoverySuggestion)) \r
@dehrom
dehrom / DataSource.swift
Last active August 12, 2022 17:17
Repository pattern impl
import Combine
import Foundation
// MARK: - Typealiases
public typealias Seal<A, B: Error> = AnyPublisher<A, B>
// MARK: - Error
public enum DataSourceError: Error {
import Foundation
@resultBuilder
public struct ArrayBuilder<T> {
public static func buildBlock() -> [T] { [] }
public static func buildExpression(_ expression: T) -> [T] { [expression] }
public static func buildExpression(_ expression: T...) -> [T] { expression }
public static func buildExpression(_ expression: T?...) -> [T] { expression.compactMap { $0 } }
public static func buildExpression(_ expression: T?) -> [T] { [expression].compactMap { $0 } }
public static func buildExpression(_ expression: [T]) -> [T] { expression }