Closed Z-JaDe closed 5 years ago
Protocol-oriented can make projects more scalable and better optimized.
Class is created inside the heap, but Struct can be optimized into the stack.
When change DefaultsKey class to struct and change DefaultsKeys class to protocol, The method of using static properties no longer applies, but fortunately, the computed property can return a Struct or Enum, which directly completes the overhead in the stack.
extension DefaultsKeys {
public static var yourKey: DefaultsKey<Bool> {
return .init("yourKey", defaultValue: false)
}
}
@Z-JaDe hey, just wanted to say that this is awesome. I'm pretty sure I want both this & #199 in the next release. In that case, would you create a new PR that bases on top of #199 (still don't close this one as there might be a slight chance #199 won't get in)? I have yet to review it but it would really help me get both of this merged as soon as possible.
Thanks again, seems like it might be a really good improvement if we can make it work with the DefaultsKeyStore
.
@sunshinejr hey, Originally thought that #199 is just a dynamicMemberLookup extension. When I looked at the documentation I found this to be a new feature of swift 5.1. However, api is still uncertain. This feature of swift5.1 is so cool, looking forward to...
Defaults.launchCount = 1
Defaults.remove.launchCount()
Defaults.hasKey.launchCount
The new PR is in #203
Awesome @Z-JaDe. Thanks a lot for doing this. Gonna review it as soon as possible, but this looks exciting!
Generated by :no_entry_sign: Danger Swift against b08e13c961d50b62200ef120728198e9aae2a226