Angular 5 个 HttpClient 事件

Angular 5 HttpClient Events

我只是想探索新的 HttpClient。知道那里有很多 HttpClient 事件(发送、上传进度、响应头、下载进度、响应和用户)。但是我找不到关于所有这些事件正在做什么的文档。我是前端开发的新手。我可以知道所有这些事件在做什么吗?提前致谢。

试过这个:

// const req = new HttpRequest('POST', 'upload-file-upload', files, {
            //     reportProgress: true
            // });
            // this.http.request(req).subscribe(event => {
            //     // Via this API, you get access to the raw event stream.
            //     // Look for upload progress events.
            //     if (event.type === HttpEventType.UploadProgress) {
            //         console.log(event, HttpEventType);
            //         this.onUpload.emit(files);
            //       // This is an upload progress event. Compute and show the % done:
            //       const percentDone = Math.round(100 * event.loaded / event.total);
            //       console.log(`File is ${percentDone}% uploaded.`);
            //     } else if (event instanceof HttpResponse) {
            //       console.log('File is completely uploaded!');
            //     }
            //   });

来自official docs,

If a HttpRequest object is passed directly, an Observable of the raw HttpEvent stream will be returned.

这些事件是您可以找到的 Http 事件 here