K
K
Konstantin2020-04-25 21:27:12
Angular
Konstantin, 2020-04-25 21:27:12

Why didn't SwitchMap work to cancel the request?

In the component, a request is made to the server via routing:

ngOnInit(): void {
    this.route.paramMap
      .pipe(
        switchMap((params) => {
          return this.managerService
            .get()
            .getVersions(params.get("orderid"));
        }),

        finalize(() => {
        })
      )
      .subscribe((data) => {
        console.log("aa");
      });
  }


If you f5 or follow the route many times, then requests are always sent to the server and are not canceled `switchMap((params) => {}). All requests receive a response.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question