import { FactoryProvider , InjectionToken } from '@angular/core' ; import { WebStorage } from './interfaces/webStorage' ; export const LOCAL_STORAGE = new InjectionToken < WebStorage > ( 'window_local_storage' ) ; export function getLocalStorage ( ) { return ( typeof window !== 'undefined' ) ? window . localStorage : null ; } export const LocalStorageProvider = { provide : LOCAL_STORAGE , useFactory : getLocalStorage } ; export const SESSION_STORAGE = new InjectionToken < WebStorage > ( 'window_session_storage' ) ; export function getSessionStorage ( ) { return ( typeof window !== 'undefined' ) ? window . sessionStorage : null ; } export const SessionStorageProvider = { provide : SESSION_STORAGE , useFactory : getSessionStorage } ;