Skip to content

Instantly share code, notes, and snippets.

@LarsBergqvist
Created February 2, 2020 10:42
Show Gist options
  • Save LarsBergqvist/6c1c31c3faed511b620f743dbd6c6af1 to your computer and use it in GitHub Desktop.
Save LarsBergqvist/6c1c31c3faed511b620f743dbd6c6af1 to your computer and use it in GitHub Desktop.
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