This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- In almost all cases where you type `@ObservedObject`, you really want `@StateObject`. | |
If you need to support iOS 13, use `@State` on parent and pass value into child with `@ObservedObject` to simulate `@StateObject`. | |
Pass arguments to that model in `onAppear`. Example: https://github.com/ra1028/SwiftUI-Hooks/blob/main/Sources/Hooks/HookScope.swift#L39-L41 | |
``` | |
.onAppear { | |
model.onAppear(userTag: userTag) | |
} | |
.onDisappear { | |
model.onDisappear() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import Combine | |
public struct ChangeObserver<V: Equatable>: ViewModifier { | |
public init(newValue: V, action: @escaping (V) -> Void) { | |
self.newValue = newValue | |
self.newAction = action | |
} | |
private typealias Action = (V) -> Void |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# blog post | |
# | |
# https://www.jessesquires.com/blog/customizing-git-log/ | |
git log --graph --pretty=format:'commit: %C(bold red)%h%Creset %C(red)<%H>%Creset %C(bold magenta)%d %Creset%ndate: %C(bold yellow)%cd %Creset%C(yellow)%cr%Creset%nauthor: %C(bold blue)%an%Creset %C(blue)<%ae>%Creset%n%C(cyan)%s%n%Creset' |