Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promote to use a Promise api instead of callbacks #4031

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions docs/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,7 @@ Abort prefetch request.
### `getSize()`

```tsx
static getSize(
uri: string,
success: (width: number, height: number) => void,
failure?: (error: any) => void,
): any;
static getSize(uri: string): Promise<{width: number, height: number}>;
```

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.
Expand All @@ -477,11 +473,9 @@ In order to retrieve the image dimensions, the image may first need to be loaded

**Parameters:**

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

---

Expand All @@ -490,10 +484,8 @@ In order to retrieve the image dimensions, the image may first need to be loaded
```tsx
static getSizeWithHeaders(
uri: string,
headers: {[index: string]: string},
success: (width: number, height: number) => void,
failure?: (error: any) => void,
): any;
headers: {[index: string]: string}
): Promise<{width: number, height: number}>;
```

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.
Expand All @@ -502,12 +494,10 @@ In order to retrieve the image dimensions, the image may first need to be loaded

**Parameters:**

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

---

Expand Down