# Session Service

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

## Requirements

The Session Service interface:

```typescript
export interface SessionServiceInterface {
  getSessionId(): Observable<string>;
}
```

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

```typescript
…
import {SessionServiceInterface} from '@vendasta/session-service';

@Injectable()
export class SessionService implements SessionServiceInterface {
  …
  getSessionId(): Observable<string> {
    // Implement how the project determines the session id
  }
}
```

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

```typescript
import { SessionService } from './session.service';
import { SessionServiceInterfaceToken } from '@vendasta/session-service';
…
@NgModule({
  …
  providers: [
    SessionService, {provide: SessionServiceInterfaceToken, useExisting: SessionService}
  ],
})
```

* Note: To be able to inject an interface, you will have to provide the InjectionToken and not the interface itself (`SessionServiceInterfaceToken` vs `SessionServiceInterface`).
