Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
404: Not Found
Github
link |
Stars: 693 |
Related Packages
You may find interesting
Releases
- 2020-08-28T21:46:08
- Add ability to subscribe to multiple keys https://github.com/sindresorhus/Defaults/commit/ab8127604c7f8b5ed9b6369e4d1ec5fb1b39b971
- Add ability to prevent event propagation https://github.com/sindresorhus/Defaults/commit/ab8127604c7f8b5ed9b6369e4d1ec5fb1b39b971
https://github.com/sindresorhus/Defaults/compare/v4.0.0...v4.1.0
- 2020-04-18T07:51:05
Important
If you use Swift Package Manager, you need to set the build setting “Other Linker Flags” to -weak_framework Combine
to work around this Xcode bug.
Breaking
- Get rid of
Defaults.OptionalKey
https://github.com/sindresorhus/Defaults/commit/b2fdee2055c87149bef0b2fec0726a87c191926c- Migrate:
extension Defaults.Keys {
- static let name = OptionalKey<Double>("name")
+ static let name = Key<Double?>("name")
}
- Remove the
.old
and.new
options forDefaults.observe
https://github.com/sindresorhus/Defaults/commit/8376ca7f5157d692b010e731878a82b49ba1c70e- They're now the default. There was no good reason to not specify them and it was easy to leave them out by accident and then getting the incorrect
.newValue
/.oldValue
.
- They're now the default. There was no good reason to not specify them and it was easy to leave them out by accident and then getting the incorrect
- Rename
DefaultsObservation
toDefaults.Observation
https://github.com/sindresorhus/Defaults/commit/31b56ce018f03b07cc335960d8f7aa1d49d9b0f8
Improvements
- Add
@Default
property wrapper for SwiftUI https://github.com/sindresorhus/Defaults/commit/12a65c057d0defa2fb500dd15ae4255fb274f16e - Add Combine publishers https://github.com/sindresorhus/Defaults/commit/6029ac796b7bc75edf54acc7adf42e169eadbe9b
.reset()
now actually removes the item instead of just setting its value tonil
.
Fixes
Defaults.reset()
now works with keys of different types, but it's limited to 10 keys because of Swift generics limitations https://github.com/sindresorhus/Defaults/commit/15c096d7fd7e7ef0ad4e4824cb3f96bad941440f
https://github.com/sindresorhus/Defaults/compare/v3.1.1...v4.0.0
- 2019-10-30T12:49:24
- Fix availability checks for CocoaPods https://github.com/sindresorhus/Defaults/commit/a82d6728e7da6cfc5f23bbae79877bded3a969e9
- 2019-10-30T12:11:48
- 2019-09-11T08:07:20
Breaking
- Require Xcode 11 and Swift 5.1 for building https://github.com/sindresorhus/Defaults/commit/90ac6f88021e22d58b109b71866bd21471b898fe
- Switch from
defaults
toDefaults
https://github.com/sindresorhus/Defaults/commit/90ac6f88021e22d58b109b71866bd21471b898fe Example:defaults[.unicorn]
→Defaults[.unicorn]
Example:defaults.observable
→Defaults.observable
- Rename
defaults.clear
toDefaults.removeAll
and make it a static method https://github.com/sindresorhus/Defaults/commit/27c9997134dacd097b912a39a685ea71a0a57b89
Enhancements
- Add
.reset()
method to reset the given keys back to their default value https://github.com/sindresorhus/Defaults/commit/d1e42154f9a2c9c7375849bd376b99a48deda47b
- 2019-07-25T01:55:16
- Fix the source file location for SwiftPM https://github.com/sindresorhus/Defaults/commit/674fde4974ffeb8cb4de02d4977a20e74dcea40a
- 2019-07-08T07:09:56
- Fix Swift 5 upgrade warning https://github.com/sindresorhus/Defaults/commit/865a4b0ff33d1e4b04382d60e808d16ce53c0775
- 2019-04-05T07:30:51
- Upgrade to and require Swift 5. https://github.com/sindresorhus/Defaults/commit/908d3b4ee17e4f7534750d55a0fa2e532ff4f18b
- 2018-10-17T10:37:38
Key observation
You can now observe changes to keys in a strongly-typed fashion. It even preserves the type of the oldValue
and newValue
keys in the change event.
extension Defaults.Keys {
static let isUnicornMode = Key<Bool>("isUnicornMode", default: false)
}
let observer = defaults.observe(.isUnicornMode) { change in
// Initial event
print(change.oldValue)
//=> false
print(change.newValue)
//=> false
// First actual event
print(change.oldValue)
//=> false
print(change.newValue)
//=> true
}
defaults[.isUnicornMode] = true
Shorter syntax
extension Defaults.Keys {
- static let quality = Defaults.Key<Double>("quality", default: 0.8)
+ static let quality = Key<Double>("quality", default: 0.8)
}
Support for alternative UserDefaults suites
let extensionDefaults = UserDefaults(suiteName: "com.unicorn.app")!
extension Defaults.Keys {
static let isUnicorn = Key<Bool>("isUnicorn", default: true, suite: extensionDefaults)
}
defaults[.isUnicorn]
//=> true
// Or
extensionDefaults[.isUnicorn]
//=> true
Registers default values with the native UserDefaults
When you use, for example:
extension Defaults.Keys {
static let quality = Key<Double>("quality", default: 0.8)
}
It will register 0.8
as the default value with UserDefaults, which can then be used in other contexts, like binding in Interface Builder.