why should we use subscribe() over map() in Angular?

前端 未结 5 1498
花落未央
花落未央 2020-12-07 22:28

I am trying to take advantage of observables in angular2 and got confused on why should i use map() over subscribe(). Suppose i am getting values f

5条回答
  •  無奈伤痛
    2020-12-07 22:42

    You need subscribe to run your async request. If you just set map - no requests will trigger. You can check.

    Good practice to use map to preproccess you data because many subscribers can comsume your results. So instead of adding preprocessing to each client (subscriber) you can prepare single output with single data schema for all.

提交回复
热议问题