What is the correct way to share the result of an Angular Http network call in RxJs 5?

前端 未结 21 1344
广开言路
广开言路 2020-11-21 06:11

By using Http, we call a method that does a network call and returns an http observable:

getCustomer() {
    return          


        
21条回答
  •  醉梦人生
    2020-11-21 06:22

    Great answers.

    Or you could do this:

    This is from latest version of rxjs. I am using 5.5.7 version of RxJS

    import {share} from "rxjs/operators";
    
    this.http.get('/someUrl').pipe(share());
    

提交回复
热议问题