1.0.2 • Published 7 years ago

@vendasta/environment-service v1.0.2

Weekly downloads
10
License
ISC
Repository
-
Last release
7 years ago

Environment Service

This provides a service for other components to use to retrieve environment information.

Requirements

The Environment Service interface:

export interface EnvironmentServiceInterface {
    getEnvironment(): Environment;
}

To implement the interface make a new service that implements the interface:

…
import {EnvironmentServiceInterface, Environment} from '@vendasta/environment-service';

@Injectable()
export class EnvironmentService implements EnvironmentServiceInterface {
  …
  getEnvironment(): Environment {
    // Implement how the project determine which environment to run in.
  }
}

Next you will need to provide your service as that interface (generally in app.module.ts)

import { EnvironmentService } from './environment.service';
import { EnvironmentServiceInterfaceToken } from '@vendasta/environment-service';
…
@NgModule({
  …
  providers: [
    EnvironmentService, {provide: EnvironmentServiceInterfaceToken, useExisting: EnvironmentService}
  ],
})
  • Note: To be able to inject an interface, you will have to provide the InjectionToken and not the interface itself (EnvironmentServiceInterfaceToken vs EnvironmentServiceInterface).