Cold and hot publishers: share, multicast and Future — what runs how many times?
The gist
A cold publisher starts its work anew on every subscription and separately for each subscriber: dataTaskPublisher, Just, Deferred, Sequence.publisher. Two sinks on one dataTaskPublisher mean two HTTP requests. A hot publisher produces values independently of subscribers and hands the same ones to all current subscribers: subjects, @Published, NotificationCenter.publisher, Timer.publish after connect.
Operators inherit coldness: map, decode, handleEvents run separately for each subscriber. Hence duplicated requests, double logging and side effects executed N times.
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep