Skip to content

Commit

Permalink
memoize computationally expensive calls
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherchrisberry committed Feb 9, 2015
1 parent 8b95613 commit c23bc1a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/scripts/modules/account/accountService.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ angular.module('deckApp.account.service', [
});
}

function getRegionsKeyedByAccount() {
var getRegionsKeyedByAccount = _.memoize(function() {
var deferred = $q.defer();
listAccounts().then(function(accounts) {
$q.all(accounts.reduce(function(acc, account) {
Expand All @@ -94,7 +94,7 @@ angular.module('deckApp.account.service', [
});
});
return deferred.promise;
}
});

function getAccountDetails(accountName) {
return Restangular.one('credentials', accountName)
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/services/awsInstanceTypeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ angular.module('deckApp.aws.instanceType.service', [
return $q.when(categories);
}

function getAllTypesByRegion() {
var getAllTypesByRegion = _.memoize(function getAllTypesByRegion() {

var instanceTypesEndpoint = Restangular.withConfig(function (RestangularConfigurer) {
RestangularConfigurer.setDefaultHttpFields({cache: true});
Expand All @@ -261,7 +261,7 @@ angular.module('deckApp.aws.instanceType.service', [
return instanceTypesEndpoint.all('instanceTypes').getList().then(function (types) {
return _.groupBy(types, 'region');
});
}
});

function getAvailableTypesForRegions(availableRegions, selectedRegions) {
selectedRegions = selectedRegions || [];
Expand Down

0 comments on commit c23bc1a

Please sign in to comment.