Ext.define("IceCap.state.local.Provider", {

	xtype: "icecap-state-local-provider",

	extend: "Ext.state.Provider",

	requires: [
		"Ext.state.Provider"
	],

	set: function(s_key, value) {

		var s_value = JSON.stringify(value);

		localStorage.setItem("icecap-" + s_key, s_value);
	},

	get: function (s_key, defaultValue) {

		var value = localStorage.getItem("icecap-" + s_key);

		try {
			value = JSON.parse(value);
		}
		catch (err) {
			value = defaultValue;
		}

        return value;
	},

	clear: function(s_key) {

        localStorage.removeItem("icecap-"+ s_key, null);
	}
});
