Skip to content

Commit 3c773ed

Browse files
committed
Add upload progress notification
1 parent 543fecc commit 3c773ed

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/execute.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export default function execute<T>(request: httpclient.Request): Promise<httpcli
2727
const xhr = new XMLHttpRequest()
2828
xhr.withCredentials = request.withCredentials
2929
xhr.timeout = request.timeout
30+
xhr.upload.onloadstart = request.upload.onloadstart
31+
xhr.upload.onprogress = request.upload.onprogress
3032

3133
// This internal method takes the xml request and retrieves headers from it
3234
const parseResponseHeaders = function(request: XMLHttpRequest): httpclient.Headers {

src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ export namespace httpclient {
7575
}
7676
// Contains every parameter needed for a request as properties
7777
export class Request {
78+
upload: {
79+
onprogress: { (event: Event): void }
80+
onloadstart: { (event: Event): void }
81+
}
7882
url: string
7983
contentType: string = 'application/json; charset=UTF-8'
8084
// A way to declare an enumeration (can be anything because of the string but the IDE will suggest the 4 first verbs)
@@ -117,6 +121,10 @@ export namespace httpclient {
117121
if (timeout) {
118122
this.timeout = timeout
119123
}
124+
this.upload = {
125+
onprogress: () => void 0,
126+
onloadstart: () => void 0
127+
}
120128
}
121129

122130
// sets the properties (like a constructor for changes)

0 commit comments

Comments
 (0)