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.

preloadImage.native.js 562B

123456789101112131415161718192021222324252627
  1. // @flow
  2. import { Image } from 'react-native';
  3. import { isIconUrl } from './functions';
  4. /**
  5. * Tries to preload an image.
  6. *
  7. * @param {string | Object} src - Source of the avatar.
  8. * @returns {Promise}
  9. */
  10. export function preloadImage(src: string | Object): Promise<Object> {
  11. if (isIconUrl(src)) {
  12. return Promise.resolve(src);
  13. }
  14. return new Promise((resolve, reject) => {
  15. Image.prefetch(src).then(
  16. () => resolve({
  17. src,
  18. isUsingCORS: false
  19. }),
  20. reject);
  21. });
  22. }