Sindre Sorhus

Results 4147 comments of Sindre Sorhus

Yeah, that looks good. Should be `Defaults.observe(Defaults.Keys.test, options: []) { keyChange in` so it doesn't trigger an initial update.

Don't forget to make the self access weak in the closure though.

> Basically, this means that any solution that involves a var will cause warnings and/or errors. Use a [lock](https://github.com/sindresorhus/Defaults/blob/a89f799930c92a85aa04b72131849d46c0833ab3/Sources/Defaults/Utilities.swift#L252) and mark the variable with `@unchecked Sendable`.

I was thinking there was a keyword for ignoring sendable, but what I meant was wrap it in an unchecked sendable box: ```swift final class LockedSendableValue: @unchecked Sendable { private...

How about something like this? This also correctly destroys the event subscription when the class deinits: ```swift extension Defaults.Keys { static let test = Key("test", default: "") } @Observable final...

Friendly bump in case you forgot about this :)

This works great! Tested it in a real app. Nice work. --- Only one problem left. When enabling Swift 6 mode, I get a warning: > /var/folders/ng/1dc3svp96z36746xz4czb25r0000gn/T/swift-generated-sources/@__swiftmacro_5Plash8CatModelC7catName17ObservableDefaultfMp_.swift:1:20 Static property '_objcAssociatedKey_catName'...

@kevinrpb This looks good from my side. Maybe you want to take a last look over and approve this before I merge?

Thanks for contributing 🙏