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 451B

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