import { FactoryProvider , InjectionToken } from '@angular/core' ; import { CrossStorageClient } from 'cross-storage' ; import { CROSS_STORAGE_CONFIG , CrossStorageConfig } from '../config' ; export interface CrossStorageClientI { onConnect ( ) : Promise < any > ; set ( key , value ) : Promise < any > ; get ( key ) : Promise < any > ; clear ( key ? ) : Promise < any > ; del ( key ? ) : Promise < any > ; } export const CROSS_STORAGE_CLIENT = new InjectionToken < CrossStorageClientI > ( 'cross_storage_client' ) ; export function getCrossStorageClient ( { host } ) { return new CrossStorageClient ( host ) ; } export const CrossStorageClientProvider = { provide : CROSS_STORAGE_CLIENT , useFactory : getCrossStorageClient , deps : [ CROSS_STORAGE_CONFIG ] , } ;