-
Notifications
You must be signed in to change notification settings - Fork 83
Defaults persistence storage abstraction #32
base: master
Are you sure you want to change the base?
Conversation
I don't know if you already know this, but |
Oh I had not seen the code of the demo - just checked it out. The fact that this lib uses Also, there's no guarantee that the key that the app specifies is exactly the key the lib uses to store the settings - the lib could easily had prefixes for example or not use the standard NSUserDefaults. For these reasons, I think the lib should offer a way to specify default values. In the future, the persistence storage could be abstracted and the lib could even support multiple storage options (ex: CoreData, sqlite, Parse, Realm, etc...) |
Ok, so now we're discussing a larger matter: abstracting the defaults persistence storage. I'm curious about how well we could implement this. My bet is we can make a pretty good job. I'll open an issue to discuss future breaking changes for 4.0 (which I'm planning to rewrite entirely in Swift) and reference this one there. |
@davdroman I dont think this PR should be renamed. The persistence storage abstraction is not a requirement to adopt good habits of hiding implementation details. |
@gmoledina I'm sorry if that bothered you, I didn't mean to. The thing is I really want to hide those implementation details, but I don't think is worth it in this current version. Bohr already provides what this PR is trying to achieve indirectly because it relies uniquely on I think it'd be far more convenient and straightforward to do the right thing and abstract the storage layer in the next major version and leaving this one depending on |
@davdroman no no I'm not bothered at all, dont worry ! Alright no problem, I see your point. |
3b2804d
to
658a540
Compare
Settings always need default values so that :
The suggestion is to add this simple method in the Setting model class that will serve just that : easily specify default values for when no values have been set yet.
Usage example:
This method would be called in the app delegate during app launch so that all ViewControllers already have valid values for the settings to start with.