Skip to content

Instantly share code, notes, and snippets.

View danielt1263's full-sized avatar

Daniel Tartaglia danielt1263

View GitHub Profile
@danielt1263
danielt1263 / Coordinator.swift
Last active February 11, 2025 01:02
A nice little Coordinator class that allows you to design the view hierarchy of your app outside of the views themselves. It also can handle runtime updating of the hierarchy for e.g. from a network request.
//
// Coordinator.swift
//
// Created on 1 Feb 2025.
// Copyright © 2025 Daniel Tartaglia. MIT License.
//
import SwiftUI
@Observable
//
// URLRequest+curlCommand Tests.swift
//
// Created by Daniel Tartaglia on 21 Nov 2024.
// Copyright © 2025 Daniel Tartaglia. MIT License.
//
struct curl_command_tests {
struct first_line_tests {
@Test func firstLineContainsGETIfMissingMethod() {
//
// ThrottleDebounceLatest.swift
//
// Created by Daniel Tartaglia on 14 Oct 2023.
// Copyright © 2025 Daniel Tartaglia. MIT License.
//
import Foundation
import RxSwift
@danielt1263
danielt1263 / TokenAcquisitionService.swift
Last active August 30, 2024 06:33
The TokenAcquisitionService automatically retry requests if it receives an unauthorized error. Complete with proof that it works correctly.
//
// TokenAcquisitionService.swift
//
// Created by Daniel Tartaglia on 16 Jan 2019.
// Copyright © 2024 Daniel Tartaglia. MIT License.
//
import Foundation
import RxSwift
//
// StallUnless.swift
//
// Created by Daniel Tartaglia on 1 Oct 2018.
// Copyright © 2024 Daniel Tartaglia. MIT License.
//
import RxSwift
extension ObservableType {
@danielt1263
danielt1263 / PollContinuously+Rx.swift
Last active February 20, 2024 13:41
The pollContinuously operator is useful if you want to subscribe to an Observable again after it finishes...
//
// PollContinuously+Rx.swift
//
// Created by Daniel Tartaglia on 20 Jun 2023.
// Copyright © 2023 Daniel Tartaglia. MIT License.
//
import RxSwift
extension ObservableType {
//
// UITextViewExtensions.swift
//
// Created by Daniel Tartaglia on 7/20/17.
// Copyright © 2017 Daniel Tartaglia. MIT License.
//
import UIKit
extension UITextField {
@danielt1263
danielt1263 / ClearingDebounceTests.swift
Last active July 21, 2023 16:29
A conditional debounce operator.
class Tests: XCTestCase {
var scheduler: TestScheduler!
var result: TestableObserver<String>!
var disposeBag: DisposeBag!
override func setUp() {
super.setUp()
scheduler = TestScheduler(initialClock: 0, resolution: 0.1)
result = scheduler.createObserver(String.self)
disposeBag = DisposeBag()
@danielt1263
danielt1263 / SharedCache+Rx.swift
Last active June 20, 2023 10:51
I was asked to create a shared cache.
//
// SharedCache+Rx.swift
//
// Created by Daniel Tartaglia on 12 Jun 2021.
// Copyright © 2023 Daniel Tartaglia. MIT License.
//
import RxSwift
extension ObservableType {
@danielt1263
danielt1263 / RetryWhen.swift
Last active April 25, 2023 09:40
I have implemented RetryWhen in Combine.
//
// RetryWhen.swift
// CombineSandbox
//
// Created by Daniel Tartaglia on 9/27/19.
// Copyright © 2019 Daniel Tartaglia. MIT License.
//
import Foundation
import Combine