Persistent

master

⚙️ A tiny property wrapper for UserDefaults. Only 60 lines of code.
mezhevikin/Persistent

⚙️ A tiny property wrapper for UserDefaults. Only 60 lines of code.

import Persistent

extension UserDefaults {
    
    // Optional property
    @Persistent("login", .standard)
    static var login: String?
    
    // Property with default value
    @Persistent("isDarkMode", false)
    static var isDarkMode: Bool
}
UserDefaults.login = "mezhevikin"
UserDefaults.isDarkMode = true

Combine

let subscription = UserDefaults.$isDarkMode.sink {
    print($0)
}
UserDefaults.isDarkMode = true

Swift Package Manager

https://github.com/mezhevikin/persistent.git

Inspired Antonie Van Der Lee

Description

  • Swift Tools 5.5.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Oct 18 2024 23:24:03 GMT-0900 (Hawaii-Aleutian Daylight Time)