Angular Http - toPromise or subscribe

前端 未结 3 1880
走了就别回头了
走了就别回头了 2021-02-03 23:11

I have watch a few courses on Angular and have found there are different ways to manage data from an Http request.

  • Using Observables, .map(), .s
3条回答
  •  不思量自难忘°
    2021-02-03 23:21

    If you like the reactive programming style and want to be consistent within your application to always use observables even for single events (instead of streams of events) then use observables. If that doesn't matter to you, then use toPromise().

    One advantage of observables is, that you can cancel the request.

    See also Angular - Promise vs Observable

提交回复
热议问题