Session Service
This provides a service for other components to use to retrieve session information.
Requirements
The Session Service interface:
export interface SessionServiceInterface {
getSessionId(): Observable<string>;
}
To implement the interface make a new service that implements the interface:
…
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
)
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
vsSessionServiceInterface
).