1.0.2 • Published 7 years ago

@vendasta/session-service v1.0.2

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

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 vs SessionServiceInterface).