Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
🤔🤔🤔

Isaac Carol Weisberg isaac-weisberg

💭
🤔🤔🤔
View GitHub Profile
View indriver-test-problem-but-dont-tell-anybody.swift
// // Given a = "23" b = "24"
// // Returns = "47"
func sumMaker(a: String, b: String) -> String {
let a = a.reversed()
let b = b.reversed()
var resultString = String()
var index = 0
View basic-coord-tree.swift
class ProfileBasicCoordinator {
let view: UIViewController
let di: DI
let done = PublishRelay<Void>()
let disposeBag = DisposeBag()
weak var profileController: ProfileController?
init(view: UIViewController, di: DI) {
View CombineLatestSuperprimePt2.swift
func a() {
let first = Observables.just(())
let second = Observables.just(())
// will use the super-prime implementation
// because both are sync and all sync
// schedulers and synchronized in relation
// to each other
_ = Observables.combineLatest(first, second) { _, _ in () }
}
View CombineLatestSuperPrime.swift
func a() {
let first = Observables.just(())
let second = Observables.just(())
// will use the super-prime implementation
// because both are sync and all sync
// schedulers are always equal to each other
_ = Observables.combineLatest(first, second) { _, _ in () }
}
View Qutex.swift
class Qutex<Value> {
var value: Value
init(value: Value) {
self.value = value
}
let queue = DispatchQueue(label: "net.caroline-weisberg.qutex",
attributes: [.concurrent])
View AppDelegate.swift
controller.viewModel.authError
.bind(onNext: { [unowned controller] error in
let authController = AuthErrorController.instantiate()
authController.viewModel = AuthErrorViewModel(presenter: error)
authController.viewModel.logIn
.bind(onNext: { [unowned controller] _ in
controller.dismiss(animated: true)
})
View MainViewModel.4.swift
authError = forecast
.map { result -> AuthErrorModelRepresentable? in
switch result.lastResult {
case .none, .success:
return nil
case .failure(let reason):
switch reason {
case .downloadError(let reason):
switch reason {
case .download(let reason):
View AuthErrorFromMain.swift
import UIKit
struct AuthErrorFromMain: AuthErrorModelRepresentable {
var authErrorModel: AuthErrorModelType {
return AuthErrorModel(
title: "Authorization issue",
description: "You have tried to get a forecast, but it seems that you aren't logged in",
image: [
"timmyb",
"idupes",
View MainViewController.3.swift
viewModel.majorError
.bind(onNext: { [unowned self] error in
let errorUserFriendly = error.errorTitleSingular
let alert = UIAlertController(
title: errorUserFriendly.title,
message: errorUserFriendly.singularDescription,
preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: { _ in }))
View MainViewModel.3.swift
extension BusinessLogicError: ErrorTitledSingularRepresentable {
var errorTitleSingular: ErrorTitledSingularType {
switch self {
case .temperatureInvalid(let temp):
return ErrorTitledSingular("No wait", "\(temp) doesn't seem quite right")
case .downloadError(let reason):
return reason.errorTitleSingular
}
}
}
You can’t perform that action at this time.