1 | import * as definition from '.';
|
2 | import { EventData, Observable } from '../../data/observable';
|
3 | import * as imageSource from '../../image-source';
|
4 | export interface DownloadRequest {
|
5 | url: string;
|
6 | key: string;
|
7 | completed?: (image: any, key: string) => void;
|
8 | error?: (key: string) => void;
|
9 | }
|
10 | export declare class Cache extends Observable implements definition.Cache {
|
11 | static downloadedEvent: string;
|
12 | static downloadErrorEvent: string;
|
13 | placeholder: imageSource.ImageSource;
|
14 | maxRequests: number;
|
15 | private _enabled;
|
16 | private _pendingDownloads;
|
17 | private _queue;
|
18 | private _currentDownloads;
|
19 | enableDownload(): void;
|
20 | disableDownload(): void;
|
21 | push(request: DownloadRequest): void;
|
22 | enqueue(request: DownloadRequest): void;
|
23 | private _addRequest;
|
24 | private _mergeRequests;
|
25 | get(key: string): any;
|
26 | set(key: string, image: any): void;
|
27 | remove(key: string): void;
|
28 | clear(): void;
|
29 | _downloadCore(request: definition.DownloadRequest): void;
|
30 | _onDownloadCompleted(key: string, image: any): void;
|
31 | _onDownloadError(key: string, err: Error): void;
|
32 | private _shouldDownload;
|
33 | private _download;
|
34 | private _updateQueue;
|
35 | }
|
36 | export interface Cache {
|
37 | on(eventNames: string, callback: (args: EventData) => void, thisArg?: any): void;
|
38 | on(event: 'downloaded', callback: (args: definition.DownloadedData) => void, thisArg?: any): void;
|
39 | on(event: 'downloadError', callback: (args: definition.DownloadError) => void, thisArg?: any): void;
|
40 | }
|