123456789101112131415161718192021222324252627 |
-
- // @flow
-
- import { Image } from 'react-native';
-
- import { isIconUrl } from './functions';
-
- /**
- * Tries to preload an image.
- *
- * @param {string | Object} src - Source of the avatar.
- * @returns {Promise}
- */
- export function preloadImage(src: string | Object): Promise<Object> {
- if (isIconUrl(src)) {
- return Promise.resolve(src);
- }
-
- return new Promise((resolve, reject) => {
- Image.prefetch(src).then(
- () => resolve({
- src,
- isUsingCORS: false
- }),
- reject);
- });
- }
|