Hot and Cold observables: are there 'hot' and 'cold' operators?

前端 未结 4 1953
一生所求
一生所求 2020-11-22 12:58

I reviewed the following SO question: What are the Hot and Cold observables?

To summarize:

  • a cold observable emits its values when it has an observer t
4条回答
  •  北海茫月
    2020-11-22 13:37

    values in your codepen is lazy - nothing happens until something subscribes, at which point it runs through and wires it up. So in your example, although you are subscribing to the same variable, it is creating two different streams; one for each subscribe call.

    You can think of values as being a generator of streams for click with that map attached.

    .share() on the end of that map would create the behaviour we expect, because it is implicitly subscribing.

提交回复
热议问题