I’m looking for some guidance on best practice here. I need to load or create a single model which contains some user preferences. I am using local storage for this particular model.
So far, I haven’t had much luck. Here’s what I have:
# There may or may not be App.UserSettings in local storage
settings = App.UserSettings.find()
settings.addObserver "didLoad", (editors) ->
console.debug "never reached"
settings = settings.get("firstObject")
With the asynchronous pattern, how do I account for the case where there are no App.UserSettings in local storage?
I could be thinking about this with old synchronous habits, so if someone could please point out where I’m going wrong, it would be greatly appreciated.
How do I determine that no records of this type exist?