Skip to content

Instantly share code, notes, and snippets.

Created February 2, 2020 10:42
What would you like to do?
Factory function for creating a real service or a mock service
export function locationsServiceFactory() {
return (http: HttpClient, configService: AppConfigService, logging: LoggingService): LocationsService => {
if (configService.useFakeData) {
logging.logInfo('use mock service');
return new LocationsServiceMock();
} else {
logging.logInfo('use real service');
return new LocationsServiceImpl(http, configService);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment