I watched the video and I know the general principles – hot happens even when nobody is subscribed, cold happens “on demand”.
Also, Publish() converts cold to hot and Defer() converts hot to cold.
But still, I feel I am missing the details. Here are some questions I’d like to have answered:
- Can you give a comprehensive definition for these terms?
- Does it ever make sense to call Publish on a hot observable or Defer on a cold?
- What are the aspects of Hot/Cold conversions – do you lose messages, for example?
- Are there differences between hot and cold definitions for IObservable and IEnumerable?
- What are the general principles you should take into account when programming for cold or hot?
- Any other tips on hot/cold observables?
I hope this helps.
See my blog post at: https://leecampbell.com/2010/08/19/rx-part-7-hot-and-cold-observables
No, not that I can think of.
It is possible to "lose" messages when the Observable is Hot, as "events" happen regardless of subscribers.
I dont really understand the question. I hope this analogy helps though. I would compare a Hot Observable to an Eagerly evaluated IEnumerable. ie a List or an Array are both Eagerly evaluated and have been populated even if no-one enuemerates over them. A yield statement that gets values from a file or a database could be lazily evaluated with the Yield keyword. While lazy can be good, it will by default, be reevaluated if a second enumerator runs over it. Comparing these to Observables, a Hot Observable might be an Event (Button click) or a feed of temperatures; these events will happen regardless of a subscription and would also be shared if multiple subscriptions were made to the same observale. Observable.Interval is a good example of a Cold observable. It will only start producing values when a subscription is made. If multiple subscriptions as made then the sequence will be re-evaluated and the "events" will occur at seperate times (depending on the time between subscriptions).
Refer to the link in point one. I would also recommend you look into Publsh being used in conjunction with RefCount. This allows you to have the ability to have Lazy evaluation semantics of Cold Observables but the sharing of events that Hot Observables get.
Get your hands dirty and have a play with them. Once you have read about them for more than 30minutes, then time spent coding with them is far more productive to you than reading any more 🙂