Class: SC.UserDefaults


Extends SC.Object.

The UserDefaults object provides an easy way to store user preferences in your application on the local machine. You use this by providing built-in defaults using the SC.userDefaults.defaults() method. You can also implement the UserDefaultsDelegate interface to be notified whenever a default is required.

You should also set the userDomain property on the defaults on page load. This will allow the UserDefaults application to store/fetch keys from localStorage for the correct user.

You can also set an appDomain property if you want. This will be automatically prepended to key names with no slashes in them.

SC.userDefaults.getPath("global:contactInfo.userName");

Defined in: user_defaults.js

Since:
SproutCore 1.0

Field Summary

Instance Methods

Field Detail

appDomain

The default app domain for the user. Any keys that do not include a slash will be prefixed with this app domain key when getting/setting.

userDomain

the default domain for the user. This will be used to store keys in local storage. If you do not set this property, the wrong values may be returned.

Instance Method Detail

defaults(newDefaults)

Invoke this method to set the builtin defaults. This will cause all properties to change.

Parameters:
newDefaults
init()
readDefault(keyName)

Attempts to read a user default from local storage. If not found on localStorage, use the the local defaults, if defined. If the key passed does not include a slash, then add the appDomain or use "app/".

Parameters:
keyName String
Returns:
Object
read value
resetDefault(keyName)
Removed the passed keyName from the written hash and local storage.
Parameters:
keyName String
Returns:
SC.UserDefaults
receiver
unknownProperty(key, value)
Is called whenever you .get() or .set() values on this object
Parameters:
key Object
value Object
Returns:
Object
writeDefault(keyName, value)

Attempts to write the user default to local storage or at least saves them for now. Also notifies that the value has changed.

Parameters:
keyName String
value Object
Returns:
SC.UserDefault
receiver
Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 08 2015 10:02:21 GMT-0600 (CST)