Created
March 22, 2015 22:39
-
-
Save ianjosephwilson/fd7d10d57566ac8a56d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function startWatchingTagSettings() { | |
var request = null, timeout = null, temp = null, rate = 300; | |
$scope.$watch('tagSettings', function (val, oldVal) { | |
if (val === oldVal) { | |
// Special case where we are called durining initialization. | |
return; | |
} | |
temp = val; | |
if (timeout) { | |
$timeout.cancel(timeout); | |
} | |
if (request) { | |
request.abort(); | |
request = null; | |
} | |
timeout = $timeout(function() { | |
console.log('updating the tag settings'); | |
request = TagService.updateTag($scope.tag.id, temp); | |
}, rate); | |
}, true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment