2017-08-18 19:52:41 +00:00
|
|
|
import { ImageCache } from './';
|
2017-08-03 17:43:04 +00:00
|
|
|
|
|
|
|
/**
|
2017-10-01 06:35:19 +00:00
|
|
|
* Notifies about the successful download of an {@code Image} source. The name
|
|
|
|
* is inspired by {@code Image}. The downloaded {@code Image} source is not
|
2017-08-03 17:43:04 +00:00
|
|
|
* available because (1) I do not know how to get it from {@link ImageCache} and
|
|
|
|
* (2) we do not need it bellow. The function was explicitly introduced to cut
|
2017-10-01 06:35:19 +00:00
|
|
|
* down on unnecessary {@code ImageCache} {@code observer} instances.
|
2017-08-03 17:43:04 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
function _onLoad() {
|
|
|
|
// ImageCache requires an observer; otherwise, we do not need it because we
|
|
|
|
// merely want to initiate the download and do not care what happens with it
|
|
|
|
// afterwards.
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-10-01 06:35:19 +00:00
|
|
|
* Initiates the retrieval of a specific {@code Image} source (if it has not
|
2017-08-03 17:43:04 +00:00
|
|
|
* been initiated already). Due to limitations of {@link ImageCache}, the source
|
2017-10-01 06:35:19 +00:00
|
|
|
* may have at most one {@code uri}. The name is inspired by {@code Image}.
|
2017-08-03 17:43:04 +00:00
|
|
|
*
|
2017-10-01 06:35:19 +00:00
|
|
|
* @param {Object} source - The {@code Image} source with preferably exactly
|
|
|
|
* one {@code uri}.
|
2017-08-03 17:43:04 +00:00
|
|
|
* @public
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
export function prefetch(source) {
|
2017-08-18 19:54:25 +00:00
|
|
|
ImageCache && ImageCache.get().on(source, _onLoad, /* immutable */ true);
|
2017-08-03 17:43:04 +00:00
|
|
|
}
|