Skip to content

Instantly share code, notes, and snippets.

View adellibovi's full-sized avatar

Alfredo Delli Bovi adellibovi

View GitHub Profile
@adellibovi
adellibovi / coroutines-recursion.swift
Last active March 22, 2025 18:05
Recursion with Swift Coroutines
import Foundation
class Tree {
let left, right: Tree?
init(left: Tree?, right: Tree?) {
self.left = left
self.right = right
}
}
let tree = (1..<100000000).reduce(Tree(left: nil, right: nil), { prev, result in
@propertyDelegate
struct State<T> {
var value: T {
get {
// Return internal storage
}
set {
// Set internal storage
// Trigger SwiftUI render enginge
}
struct CustomView : View {
@State var numOfTaps: Int = 0
var body: some View {
Text("\(numOfTaps) taps")
.tapAction { self.numOfTaps += 1 }
}
}
var body: some View {
VStack {
let a = SwiftUIBuilder.buildExpression(Text("First line"))
let b = SwiftUIBuilder.buildExpression(Text("Second line"))
return SwiftUIBuilder.buildBlock(a, b)
}
}
var body: some View {
VStack {
Text("First line")
Text("Second line")
}
}
var double: Int { x * x }
protocol View {
associatedtype Body : View
var body: some Self.Body { get }
}
@adellibovi
adellibovi / CADisplayLink+Combine.swift
Last active June 1, 2021 03:14
Swift Combine's Publisher for CADisplayLink

Keybase proof

I hereby claim:

  • I am adellibovi on github.
  • I am adellibovi (https://keybase.io/adellibovi) on keybase.
  • I have a public key ASCRkNhJxG6pmWMxX50kXabyEPXwM5MYUZexBPEbT1-f-go

To claim this, I am signing this object:

setbuf(stdout, nil)