您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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. }