Skip to content

Commit bd147b4

Browse files
committed
Promote to use a Promise api instead of callbacks
react-native pr: facebook/react-native#42895
1 parent ade0509 commit bd147b4

1 file changed

Lines changed: 10 additions & 20 deletions

File tree

docs/image.md

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,7 @@ Abort prefetch request.
464464
### `getSize()`
465465

466466
```tsx
467-
static getSize(
468-
uri: string,
469-
success: (width: number, height: number) => void,
470-
failure?: (error: any) => void,
471-
): any;
467+
static getSize(uri: string): Promise<{width: number, height: number}>;
472468
```
473469

474470
Retrieve the width and height (in pixels) of an image prior to displaying it. This method can fail if the image cannot be found, or fails to download.
@@ -477,11 +473,9 @@ In order to retrieve the image dimensions, the image may first need to be loaded
477473

478474
**Parameters:**
479475

480-
| <div className="wideColumn">Name</div> | Type | Description |
481-
| -------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------- |
482-
| uri <div class="label basic required">Required</div> | string | The location of the image. |
483-
| success <div class="label basic required">Required</div> | function | The function that will be called if the image was successfully found and width and height retrieved. |
484-
| failure | function | The function that will be called if there was an error, such as failing to retrieve the image. |
476+
| <div className="wideColumn">Name</div> | Type | Description |
477+
| ---------------------------------------------------- | ------ | -------------------------- |
478+
| uri <div class="label basic required">Required</div> | string | The location of the image. |
485479

486480
---
487481

@@ -490,10 +484,8 @@ In order to retrieve the image dimensions, the image may first need to be loaded
490484
```tsx
491485
static getSizeWithHeaders(
492486
uri: string,
493-
headers: {[index: string]: string},
494-
success: (width: number, height: number) => void,
495-
failure?: (error: any) => void,
496-
): any;
487+
headers: {[index: string]: string}
488+
): Promise<{width: number, height: number}>;
497489
```
498490

499491
Retrieve the width and height (in pixels) of an image prior to displaying it with the ability to provide the headers for the request. This method can fail if the image cannot be found, or fails to download. It also does not work for static image resources.
@@ -502,12 +494,10 @@ In order to retrieve the image dimensions, the image may first need to be loaded
502494

503495
**Parameters:**
504496

505-
| <div className="wideColumn">Name</div> | Type | Description |
506-
| -------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------- |
507-
| uri <div class="label basic required">Required</div> | string | The location of the image. |
508-
| headers <div class="label basic required">Required</div> | object | The headers for the request. |
509-
| success <div class="label basic required">Required</div> | function | The function that will be called if the image was successfully found and width and height retrieved. |
510-
| failure | function | The function that will be called if there was an error, such as failing to retrieve the image. |
497+
| <div className="wideColumn">Name</div> | Type | Description |
498+
| -------------------------------------------------------- | ------ | ---------------------------- |
499+
| uri <div class="label basic required">Required</div> | string | The location of the image. |
500+
| headers <div class="label basic required">Required</div> | object | The headers for the request. |
511501

512502
---
513503

0 commit comments

Comments
 (0)