-
-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add iCloud syncing #229
base: master
Are you sure you want to change the base?
Add iCloud syncing #229
Conversation
3554f6d
to
f142d29
Compare
Changed it so each Edit: |
Got Usage: // Prefs.swift
extension DefaultsKeys {
var username: DefaultsKey<String?> { return .init("username") }
var launchCount: DefaultsKey<Int> { return .init("launchCount", defaultValue: 0) }
}
// AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Defaults.startSyncing(for: \DefaultsKeys.launchCount, \DefaultsKeys.username)
return true
}
// ViewController.swift
@IBAction
func stopSyncingUsername(_ sender: UIButton) {
Defaults.stopSyncing(for: \DefaultsKeys.username)
}
@IBAction
func stopSyncingCompletely(_ sender: UIButton) {
Defaults.stopSyncingAll()
} @sunshinejr I think I'm now satisfied with this implementation. 😄 |
411b942
to
0234156
Compare
Hey @Stevenmagdy, the implementation (and the API!) looks really clean, thank you! Can you please:
I'll try to play with the sync as soon as possible as well! |
63f6c29
to
801999e
Compare
@sunshinejr Thanks for the reply
Done.
I'm having a hard time imagining how to test syncing. I'm very inexperienced in testing, let alone sync testing. I would appreciate any help. Unrelated question: what is |
1a71a8f
to
5a7fdf2
Compare
hey @sunshinejr, I think I'm done with this PR. I tried different approaches for testing with no luck. I hope this feature will get implemented one day 🙏, either building on this PR or from scratch. |
hey @Stevenmagdy, sorry for the delay but I'm currently really busy and have a hard time to find few minutes to play with this - I might try early next week but cannot promise anything don't worry, though, I really love the API and so we'll try to get this one in as soon as possible! and thank you for all the hard work! 🙇 |
b9274db
to
f9f7714
Compare
Although i'm going to keep my I'd like to just be able to pass
|
f9f7714
to
728c34d
Compare
728c34d
to
c0bf611
Compare
Adds #228
Usage:
Obviously the worst part of this implementation is
syncKeys
syntax and that it takes an array of closures. I tried to make it accept an array ofKeyPath
or evenPartialKeyPath
but failed so this was the best alternative.The other approach that I could have taken is for it to be without parameters and use
Mirror
internally:but i don't like using
Mirror
because i feel it's very hackyThe whole implementation is not perfect but it's acceptable given the current structure.
@sunshinejr I'm willing to take another run at it if it's not acceptable for you.
Edit: the Mirror implementation does not even work because it ignores computed properties but I'm sure we can runtime-hack it to get the keys list. still not preferred.