Created
February 2, 2020 10:42
-
-
Save LarsBergqvist/6c1c31c3faed511b620f743dbd6c6af1 to your computer and use it in GitHub Desktop.
Factory function for creating a real service or a mock service
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
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