Skip to content

Instantly share code, notes, and snippets.

View stleamist's full-sized avatar

Dongkyu Kim stleamist

View GitHub Profile
import Combine
extension Publisher {
func printError() -> Publishers.HandleEvents<Self> {
return self.handleEvents(receiveCompletion: { completion in
if case .failure(let error) = completion {
Swift.print("receive error: \(error)")
}
})
}
import KingFisher
struct KFLinkPresentationIconProvider: ImageDataProvider {
let url: URL
let cacheKey: String
init(url: URL, cacheKey: String? = nil) {
self.url = url
self.cacheKey = cacheKey ?? url.absoluteString
import Disk
@propertyWrapper
struct File<Value: Codable> {
let path: String
let directory: Disk.Directory
let defaultValue: Value
init(_ path: String, directory: Disk.Directory, defaultValue: Value) {
self.path = path
import Foundation
import KeychainAccess
@propertyWrapper
struct KeychainStorage<Value: Codable> {
let key: String
let service: String
let initialValue: Value
import Foundation
import Kingfisher
import FavIcon
struct KFFaviconProvider: ImageDataProvider {
let url: URL
let cacheKey: String
init(url: URL, cacheKey: String? = nil) {
import Foundation
@propertyWrapper
public struct NullableURL: Codable {
public let wrappedValue: URL?
public init(wrappedValue: URL?) {
self.wrappedValue = wrappedValue
}
import Foundation
@propertyWrapper
public struct PercentEncodedURL: Codable {
public let wrappedValue: URL
public init(wrappedValue: URL) {
self.wrappedValue = wrappedValue
}
import Foundation
extension URL {
init?(string: String?) {
guard let string = string else {
return nil
}
self.init(string: string)
}
import Swift
extension CaseIterable where Self: Equatable {
var index: Self.AllCases.Index {
return Self.allCases.firstIndex(of: self)!
}
}
import SwiftUI
extension View {
@ViewBuilder
func modify<Modified: View>(@ModifiedViewBuilder modificationBlock: (Self) -> Modified) -> some View {
let modified = modificationBlock(self)
if modified is EmptyView {