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: Tue Nov 08 2022 13:18:32 GMT-0500 (GMT-05:00)