Getting started with system.reactive – Sharing a single subscription (Publish + RefCount)

This code will subscribe to the emails observable twice:

emails.Where(email => email.From == "John").Subscribe(email => Console.WriteLine("A"));
emails.Where(email => email.From == "Mary").Subscribe(email => Console.WriteLine("B"));

To share a single subscription to emails, we can use Publish and RefCount instead:

var _emails = emails.Publish().RefCount();
_emails.Where(email => email.From == "John").Subscribe(email => Console.WriteLine("A"));
_emails.Where(email => email.From == "Mary").Subscribe(email => Console.WriteLine("B"));

if you want to reproduce, please indicate the source:
Getting started with system.reactive – Sharing a single subscription (Publish + RefCount) - CodeDay