# Environment Service

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

## Requirements

The Environment Service interface:

```typescript
export interface EnvironmentServiceInterface {
    getEnvironment(): Environment;
}
```

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

```typescript
…
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`)

```typescript
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`).
