Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

Commit

Permalink
adding missing docblocks and tiny tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
tymondesigns committed Feb 27, 2015
1 parent 509d216 commit c9cafdd
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 28 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-locker",
"version": "1.2.0",
"version": "1.2.1",
"homepage": "https://github.com/tymondesigns/angular-locker",
"authors": [
"Sean Tymon <[email protected]>"
Expand Down
41 changes: 29 additions & 12 deletions dist/angular-locker.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
};

/**
* Set the default driver and namespace
* Set the defaults
*
* @type {Object}
*/
Expand All @@ -76,7 +76,8 @@
* Allow setting of default storage driver via `lockerProvider`
* e.g. lockerProvider.setDefaultDriver('session');
*
* @param {String} driver
* @param {String|Function} driver
* @return {self}
*/
setDefaultDriver: function (driver) {
defaults.driver = _value(driver);
Expand All @@ -86,6 +87,8 @@

/**
* Get the default driver
*
* @return {String}
*/
getDefaultDriver: function () {
return defaults.driver;
Expand All @@ -95,7 +98,8 @@
* Allow setting of default namespace via `lockerProvider`
* e.g. lockerProvider.setDefaultNamespace('myAppName');
*
* @param {String} namespace
* @param {String|Function} namespace
* @return {self}
*/
setDefaultNamespace: function (namespace) {
defaults.namespace = _value(namespace);
Expand All @@ -105,6 +109,8 @@

/**
* Get the default namespace
*
* @return {String}
*/
getDefaultNamespace: function () {
return defaults.namespace;
Expand All @@ -113,7 +119,8 @@
/**
* Set whether the events are enabled
*
* @param {Boolean} enabled
* @param {Boolean|Function} enabled
* @return {self}
*/
setEventsEnabled: function (enabled) {
defaults.eventsEnabled = _value(enabled);
Expand All @@ -123,6 +130,8 @@

/**
* Get whether the events are enabled
*
* @return {Boolean}
*/
getEventsEnabled: function () {
return defaults.eventsEnabled;
Expand All @@ -131,7 +140,8 @@
/**
* Set the separator to use with namespace in keys
*
* @param {String} separator
* @param {String|Function} separator
* @return {self}
*/
setSeparator: function (separator) {
defaults.separator = _value(separator);
Expand All @@ -141,6 +151,8 @@

/**
* Get the separator
*
* @return {String}
*/
getSeparator: function () {
return defaults.separator;
Expand All @@ -160,6 +172,8 @@
function Locker (driver, namespace) {

/**
* Out of the box drivers
*
* @type {Object}
*/
this._registeredDrivers = {
Expand Down Expand Up @@ -281,8 +295,8 @@
/**
* Trigger an event
*
* @param {String} name
* @param {Object} payload
* @param {String} name
* @param {Object} payload
* @return {void}
*/
this._event = function (name, payload) {
Expand Down Expand Up @@ -473,7 +487,7 @@
},

/**
* Return all items in storage within the current namespace
* Return all items in storage within the current namespace/driver
*
* @return {Object}
*/
Expand All @@ -492,7 +506,7 @@
},

/**
* Remove all items set within the current namespace
* Remove all items set within the current namespace/driver
*
* @return {self}
*/
Expand Down Expand Up @@ -554,10 +568,13 @@
unbind: function ($scope, key) {
$parse(key).assign($scope, void 0);
this.forget(key);
if (this._watchers[key + $scope.$id]) {

var watchId = key + $scope.$id;

if (this._watchers[watchId]) {
// execute the de-registration function
this._watchers[key + $scope.$id]();
delete this._watchers[key + $scope.$id];
this._watchers[watchId]();
delete this._watchers[watchId];
}

return this;
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-locker.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/angular-locker.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-locker",
"version": "1.2.0",
"version": "1.2.1",
"description": "A simple & configurable abstraction for local/session storage in angular projects",
"author": "@tymondesigns",
"license": "MIT",
Expand Down
41 changes: 29 additions & 12 deletions src/angular-locker.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
};

/**
* Set the default driver and namespace
* Set the defaults
*
* @type {Object}
*/
Expand All @@ -76,7 +76,8 @@
* Allow setting of default storage driver via `lockerProvider`
* e.g. lockerProvider.setDefaultDriver('session');
*
* @param {String} driver
* @param {String|Function} driver
* @return {self}
*/
setDefaultDriver: function (driver) {
defaults.driver = _value(driver);
Expand All @@ -86,6 +87,8 @@

/**
* Get the default driver
*
* @return {String}
*/
getDefaultDriver: function () {
return defaults.driver;
Expand All @@ -95,7 +98,8 @@
* Allow setting of default namespace via `lockerProvider`
* e.g. lockerProvider.setDefaultNamespace('myAppName');
*
* @param {String} namespace
* @param {String|Function} namespace
* @return {self}
*/
setDefaultNamespace: function (namespace) {
defaults.namespace = _value(namespace);
Expand All @@ -105,6 +109,8 @@

/**
* Get the default namespace
*
* @return {String}
*/
getDefaultNamespace: function () {
return defaults.namespace;
Expand All @@ -113,7 +119,8 @@
/**
* Set whether the events are enabled
*
* @param {Boolean} enabled
* @param {Boolean|Function} enabled
* @return {self}
*/
setEventsEnabled: function (enabled) {
defaults.eventsEnabled = _value(enabled);
Expand All @@ -123,6 +130,8 @@

/**
* Get whether the events are enabled
*
* @return {Boolean}
*/
getEventsEnabled: function () {
return defaults.eventsEnabled;
Expand All @@ -131,7 +140,8 @@
/**
* Set the separator to use with namespace in keys
*
* @param {String} separator
* @param {String|Function} separator
* @return {self}
*/
setSeparator: function (separator) {
defaults.separator = _value(separator);
Expand All @@ -141,6 +151,8 @@

/**
* Get the separator
*
* @return {String}
*/
getSeparator: function () {
return defaults.separator;
Expand All @@ -160,6 +172,8 @@
function Locker (driver, namespace) {

/**
* Out of the box drivers
*
* @type {Object}
*/
this._registeredDrivers = {
Expand Down Expand Up @@ -281,8 +295,8 @@
/**
* Trigger an event
*
* @param {String} name
* @param {Object} payload
* @param {String} name
* @param {Object} payload
* @return {void}
*/
this._event = function (name, payload) {
Expand Down Expand Up @@ -473,7 +487,7 @@
},

/**
* Return all items in storage within the current namespace
* Return all items in storage within the current namespace/driver
*
* @return {Object}
*/
Expand All @@ -492,7 +506,7 @@
},

/**
* Remove all items set within the current namespace
* Remove all items set within the current namespace/driver
*
* @return {self}
*/
Expand Down Expand Up @@ -554,10 +568,13 @@
unbind: function ($scope, key) {
$parse(key).assign($scope, void 0);
this.forget(key);
if (this._watchers[key + $scope.$id]) {

var watchId = key + $scope.$id;

if (this._watchers[watchId]) {
// execute the de-registration function
this._watchers[key + $scope.$id]();
delete this._watchers[key + $scope.$id];
this._watchers[watchId]();
delete this._watchers[watchId];
}

return this;
Expand Down

0 comments on commit c9cafdd

Please sign in to comment.