You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.js 1.1KB

12345678910111213141516171819202122232425262728293031
  1. import { ImageCache } from './';
  2. /**
  3. * Notifies about the successful download of an {@code Image} source. The name
  4. * is inspired by {@code Image}. The downloaded {@code Image} source is not
  5. * available because (1) I do not know how to get it from {@link ImageCache} and
  6. * (2) we do not need it bellow. The function was explicitly introduced to cut
  7. * down on unnecessary {@code ImageCache} {@code observer} instances.
  8. *
  9. * @private
  10. * @returns {void}
  11. */
  12. function _onLoad() {
  13. // ImageCache requires an observer; otherwise, we do not need it because we
  14. // merely want to initiate the download and do not care what happens with it
  15. // afterwards.
  16. }
  17. /**
  18. * Initiates the retrieval of a specific {@code Image} source (if it has not
  19. * been initiated already). Due to limitations of {@link ImageCache}, the source
  20. * may have at most one {@code uri}. The name is inspired by {@code Image}.
  21. *
  22. * @param {Object} source - The {@code Image} source with preferably exactly
  23. * one {@code uri}.
  24. * @public
  25. * @returns {void}
  26. */
  27. export function prefetch(source) {
  28. ImageCache && ImageCache.get().on(source, _onLoad, /* immutable */ true);
  29. }