冷HTTP请求或热HTTP请求之间的区别? [英] Difference between Cold or Hot http requests?

查看:102
本文介绍了冷HTTP请求或热HTTP请求之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以向我解释两件事吗?

Could somebody explain me two things:

  • 冷HTTP请求或热HTTP请求之间的区别?
  • 在Angular 2中HTTP请求是冷还是热?

推荐答案

在Angular中,通过Http服务发出的http请求很冷.

In Angular, http requests made from the Http service are cold.

在这种情况下,冷表示在有人订阅从Http.get,Http.post等返回的observable之前,不会发出http请求.此外,对http observable的每次订阅都会导致一个不同的http请求成为被解雇.这是因为,作为一个冷可观察的对象,http的可观察对象负责在订阅时创建其生产者(即Ajax请求),并且每个订阅都将创建一个单独的值的生产者(即独立的Ajax请求).

Cold, in this context, means that the http request is not made until someone subscribes to the observable returned from Http.get, Http.post etc. Also, each subscription to an http observable will cause a different http request to be fired. This is because, as a cold observable, the http observable is responsible for creating its producer (i.e. the Ajax request) on subscription, and each subscription will create a separate producer of values (i.e. separate Ajax requests).

Thoughtram上有一篇详细的文章介绍了热与冷观测.

这篇关于冷HTTP请求或热HTTP请求之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆