Skip to content

Commit

Permalink
Added country definition interface
Browse files Browse the repository at this point in the history
  • Loading branch information
zakhenry committed Jul 23, 2015
1 parent 80cee00 commit b427694
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/src/common/services/countriesService.ts
Expand Up @@ -2,6 +2,11 @@ module common.services.countries {

export const namespace = 'common.services.countries';

export interface ICountryDefinition {
countryName:string;
countryCode:string;
}

export class CountriesService {

static $inject:string[] = ['ngRestAdapter', '$q'];
Expand All @@ -11,16 +16,16 @@ module common.services.countries {

}

private countriesCachePromise:ng.IPromise<any> = null;
private countriesCachePromise:ng.IPromise<ICountryDefinition[]> = null;

/**
* Get all countries from the API
* @returns {any}
*/
public getAllCountries() {
public getAllCountries():ng.IPromise<ICountryDefinition[]> {

//store the promise in cache, so next time it is called the countries are resolved immediately.
if (!this.countriesCachePromise){
if (!this.countriesCachePromise) {
this.countriesCachePromise = this.ngRestAdapter.get('/countries')
.then((res) => {
return res.data;
Expand Down

0 comments on commit b427694

Please sign in to comment.