* Load an item, using cache if available.
(imageFile: File, cacheKey: string)
| 223 | * Load an item, using cache if available. |
| 224 | */ |
| 225 | load(imageFile: File, cacheKey: string): Promise<T | null> { |
| 226 | const cached = state.cache.get(cacheKey); |
| 227 | if (cached) { |
| 228 | return Promise.resolve(cached); |
| 229 | } |
| 230 | |
| 231 | let promise = state.loadingPromises.get(cacheKey); |
| 232 | if (!promise) { |
| 233 | promise = queueLoad(imageFile, cacheKey); |
| 234 | state.loadingPromises.set(cacheKey, promise); |
| 235 | } |
| 236 | return promise; |
| 237 | }, |
| 238 | |
| 239 | /** |
| 240 | * Prioritize loading of a specific image. |