Skip to content

Commit 3cc4d43

Browse files
authored
Promote to use a Promise api instead of callbacks (facebook#4031)
react-native pr: facebook/react-native#42895
1 parent 13d6ef8 commit 3cc4d43

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

docs/image.md

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

486486
```tsx
487-
static getSize(
488-
uri: string,
489-
success: (width: number, height: number) => void,
490-
failure?: (error: any) => void,
491-
): any;
487+
static getSize(uri: string): Promise<{width: number, height: number}>;
492488
```
493489

494490
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.
@@ -497,11 +493,9 @@ In order to retrieve the image dimensions, the image may first need to be loaded
497493

498494
**Parameters:**
499495

500-
| <div className="wideColumn">Name</div> | Type | Description |
501-
| -------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------- |
502-
| uri <div class="label basic required">Required</div> | string | The location of the image. |
503-
| 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. |
504-
| failure | function | The function that will be called if there was an error, such as failing to retrieve the image. |
496+
| <div className="wideColumn">Name</div> | Type | Description |
497+
| ---------------------------------------------------- | ------ | -------------------------- |
498+
| uri <div class="label basic required">Required</div> | string | The location of the image. |
505499

506500
---
507501

@@ -510,10 +504,8 @@ In order to retrieve the image dimensions, the image may first need to be loaded
510504
```tsx
511505
static getSizeWithHeaders(
512506
uri: string,
513-
headers: {[index: string]: string},
514-
success: (width: number, height: number) => void,
515-
failure?: (error: any) => void,
516-
): any;
507+
headers: {[index: string]: string}
508+
): Promise<{width: number, height: number}>;
517509
```
518510

519511
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.
@@ -522,12 +514,10 @@ In order to retrieve the image dimensions, the image may first need to be loaded
522514

523515
**Parameters:**
524516

525-
| <div className="wideColumn">Name</div> | Type | Description |
526-
| -------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------- |
527-
| uri <div class="label basic required">Required</div> | string | The location of the image. |
528-
| headers <div class="label basic required">Required</div> | object | The headers for the request. |
529-
| 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. |
530-
| failure | function | The function that will be called if there was an error, such as failing to retrieve the image. |
517+
| <div className="wideColumn">Name</div> | Type | Description |
518+
| -------------------------------------------------------- | ------ | ---------------------------- |
519+
| uri <div class="label basic required">Required</div> | string | The location of the image. |
520+
| headers <div class="label basic required">Required</div> | object | The headers for the request. |
531521

532522
---
533523

0 commit comments

Comments
 (0)