This provides a service for other components to use to retrieve session information.
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}
],
})
SessionServiceInterfaceToken vs SessionServiceInterface).