You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've a scope variable that I'm watching at. Based on this variable I bind to a localForage key. In case of change, I want to unbind the 'old' value and bind the 'new'.
The current unbind method will delete the data stored for this key, what is not the intended behavior (the opposite of bind())
Either I'm wrong with my use-case and the usage of this library or unbind has a strange behavior.
To overcome my issue i currently I replaced the unbind method with:
LocalForageInstance.prototype.unbind = function unbind($scope, opts) {
if(angular.isString(opts)) {
opts = {
key: opts
}
} else if(!angular.isObject(opts) || angular.isUndefined(opts.key)) {
throw new Error("You must define a key to unbind");
}
var defaultOpts = {
scopeKey: opts.key,
name: defaultConfig.name
};
// If no defined options we use defaults otherwise extend defaults
opts = angular.extend({}, defaultOpts, opts);
var self = lfInstances[opts.name];
if(angular.isUndefined(self)) {
throw new Error("You must use the name of an existing instance");
}
// $parse(opts.scopeKey).assign($scope, null);
if(angular.isDefined(watchers[opts.key])) {
watchers[opts.key](); // unwatch
delete watchers[opts.key];
}
return $q.when(true);
};
The text was updated successfully, but these errors were encountered:
To preserve backwards compatibility, I will keep the current behavior of unbind, but we can pass another argument to the method that will decide whether to remove the value from the DB or not. Does that sound reasonable to you, @martinbrylski or anyone else who might want this behavior changed?
I've a scope variable that I'm watching at. Based on this variable I bind to a localForage key. In case of change, I want to unbind the 'old' value and bind the 'new'.
The current unbind method will delete the data stored for this key, what is not the intended behavior (the opposite of bind())
Either I'm wrong with my use-case and the usage of this library or unbind has a strange behavior.
To overcome my issue i currently I replaced the unbind method with:
The text was updated successfully, but these errors were encountered: