-
-
Save dev-sampsonorson/e42145f8684b4caa899980756e32a85e to your computer and use it in GitHub Desktop.
This file contains 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
// API Service | |
export class ApiService { | |
get(parameters: SomeParameters): Observable<ReturnType> { | |
if (!this.validate(parameters)) { | |
// throw error on failed validation | |
throw new Error('Parameters do not pass validation'); | |
} | |
return this.httpClient.get(...); | |
} | |
getOther(parameters: SomeParameters): Observable<ReturnType> { | |
if (!this.validate(parameters)) { | |
// throw error on failed validation | |
throw new Error('Parameters do not pass validation'); | |
} | |
return this.httpClient.get(...); | |
} | |
} | |
// SomeOtherService | |
export class SomeOtherService { | |
someFlag: boolean; | |
constructor(private apiService: ApiService) {} | |
getSome(someParameters: SomeParameters): Observable<Some> { | |
return iif(() => this.someFlag, this.apiService.get(someParameters), this.apiService.getOther(someParameters)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment