Skip to content

Instantly share code, notes, and snippets.

View BrunoCerberus's full-sized avatar

Bruno Mello BrunoCerberus

View GitHub Profile
@BrunoCerberus
BrunoCerberus / APIRequest.swift
Created August 6, 2023 14:56
APIRequest + APIFetcher
import Foundation
import Combine
/// HTTP Methods
public enum HTTPMethod: String {
case GET
case POST
case DELETE
case PUT
}
@BrunoCerberus
BrunoCerberus / CombineLatest.swift
Created August 13, 2023 19:55
CombineLatest of Publishers
import Combine
// A set to store any active Combine subscriptions (cancellables).
// This ensures that subscriptions are kept alive and not deallocated prematurely.
var cancellables = Set<AnyCancellable>()
// Create a publisher from an array of even integers.
let evenIntegersPublisher = [2, 4, 6, 8].publisher
// Create a publisher from an array of odd integers.
@BrunoCerberus
BrunoCerberus / Zip.swift
Created August 13, 2023 19:58
Zip Publishers
import Combine
// A set to store any active Combine subscriptions (cancellables).
// This is essential for ensuring that the subscriptions are kept alive and not deallocated prematurely.
var cancellables = Set<AnyCancellable>()
// Create a publisher from an array of even integers.
let evenIntegersPublisher = [2, 4, 6, 8].publisher
// Create a publisher from an array of odd integers.
@BrunoCerberus
BrunoCerberus / Merge.swift
Created August 13, 2023 20:14
Merge Publisher
import Combine
// A set to store any active Combine subscriptions (cancellables).
// This is essential for ensuring that the subscriptions are kept alive and not deallocated prematurely.
var cancellables = Set<AnyCancellable>()
// Create a publisher from an array of even integers.
let evenIntegersPublisher = [2, 4, 6, 8, 10].publisher
// Create a publisher from an array of odd integers.
@BrunoCerberus
BrunoCerberus / Coordinator.md
Last active August 16, 2023 07:43
Coordinator with NavigationPath

SwiftUI NavigationPath Coordinator Pattern Documentation

This documentation provides an overview of a SwiftUI implementation that employs the Coordinator pattern. The Coordinator pattern separates navigation logic from view logic, providing a centralized place to handle navigation.

Page

An enumeration representing the different pages or views available in the application.

  • home: Represents the home page of the application.
  • detail(Movie): Represents the detailed view for a particular movie.
@BrunoCerberus
BrunoCerberus / BinarySearchTree.swift
Created December 24, 2024 03:26
Below is a basic implementation of a Binary Search Tree in Swift
import UIKit
class TreeNode<T: Comparable> {
var parent: TreeNode?
var value: T
var left: TreeNode?
var right: TreeNode?
var isLeaf: Bool {
return left == nil && right == nil
struct Queue<T> {
private var elements: [T] = []
// Add an element to the back of the queue
mutating func enqueue(_ element: T) {
elements.append(element)
}
// Remove and return the front element
mutating func dequeue() -> T? {