import { Observable } from 'rxjs' ; import { PersistedLog } from './persisted_log' ; import { createLogKey } from './create_log_key' ; import { HttpSetup } from '../../http' ; public export interface ChromeRecentlyAccessedHistoryItem { link : string ; label : string ; id : string ; } interface StartDeps { http : HttpSetup ; } internal export class RecentlyAccessedService { async start ( { http } ) { const logKey = await createLogKey ( 'recentlyAccessed' , http . basePath . get ( ) ) ; const history = new PersistedLog < ChromeRecentlyAccessedHistoryItem > ( logKey , { maxLength : 20 , isEqual : ( oldItem , newItem ) => oldItem . id === newItem . id , } ) ; return { /** Adds a new item to the history. */ add : ( link , label , id ) => { history . add ( { link , label , id , } ) ; } , /** Gets the current array of history items. */ get : ( ) => history . get ( ) , /** Gets an observable of the current array of history items. */ get$ : ( ) => history . get$ ( ) , } ; } } /**
 *  ChromeRecentlyAccessed for recently accessed history.
 *  public export interface ChromeRecentlyAccessed { example param link a relative URL to the resource (not including the  HttpStart . basePath )
     *  param label param id add ( link , label , id ) : void ; example get ( ) : ChromeRecentlyAccessedHistoryItem [ ] ; example get$ ( ) : Observable < ChromeRecentlyAccessedHistoryItem [ ] > ; }