Skip to content

Commit 2e5f99f

Browse files
committed
docs: describe fetch progress listener
1 parent a9fd3ad commit 2e5f99f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ const text = await FileSystem.readFile(Dirs.CacheDir + '/test.txt');
7070
- Check if a path exists.
7171

7272
```
73-
FilesSystem.fetch(resource: string, init: { body?: string, headers?: { [key: string]: string }, method?: string, path?: string }): Promise<FetchResult>
73+
FilesSystem.fetch(
74+
resource: string,
75+
init: { body?: string, headers?: { [key: string]: string }, method?: string, path?: string },
76+
onProgress?: (bytesRead: number, contentLength: number, done: boolean) => void
77+
): Promise<FetchResult>
7478
7579
type FetchResult = {
7680
headers: { [key: string]: string };
@@ -83,6 +87,9 @@ type FetchResult = {
8387
```
8488

8589
- Save a network request to a file.
90+
- `onProgress` - Optional callback to listen to download progress. Events
91+
are rate limitted, so do not rely on `done` becoming `true`.
92+
`contentLength` is only accurate if the server sends the correct headers.
8693

8794
`FilesSystem.getAppGroupDir(groupName: string): Promise<string>`
8895

0 commit comments

Comments
 (0)