import { ImageCache } from 'react-native-img-cache';
/**
* Notifies about the successful download of an Image source. The name
* is inspired by Image. The downloaded Image source is not
* 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
* down on unnecessary ImageCache observer instances.
*
* @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.
}
/**
* Initiates the retrieval of a specific Image source (if it has not
* been initiated already). Due to limitations of {@link ImageCache}, the source
* may have at most one uri. The name is inspired by Image.
*
* @param {Object} source - The Image source with preferably exactly
* one uri.
* @public
* @returns {void}
*/
export function prefetch(source) {
ImageCache.get().on(source, /* observer */ _onLoad, /* immutable */ true);
}