title: What is the replacement for `publishReplay(1).refCount()` in RxJS version 7.4.0
body: <p>I am learning RxJS and Angular. The below code is a simplified version of rxjs-chat from the book ‘ng-book2-book-angular-11-r77.pdf’.
  It’s a simple Angular service class.
  This is what I am trying to do:</p>
  <ol>
  <li>Call from outside <code>addMessage(1)</code> method</li>
  <li>From that method I push value <code>&quot;1&quot;</code> onto <code>newMessages</code> <code>Subject</code> using <code>newMessages.next()</code> method.</li>
  <li><code>newMessages</code> subscribes in turn to <code>updates</code>(<code>Subject</code>)</li>
  <li><code>updates</code> is using <code>pipe</code> member of <code>updates</code> to <code>map</code> passed <code>message</code> into concatenated array of numbers (<code>messages</code>) and returns the concatenated array (the initial value of concatenated array is kept in <code>const initialMessages</code>).</li>
  <li>The result is stored into the <code>messages</code>(<code>Observable</code>).</li>
  <li><code>pipe</code> method also calls <code>share</code> operator so the <code>messages</code> Observable can update Observable <code>newNumbers</code> object (at least that what I thought it would do)</li>
  <li>That where my problem is  - the <code>newNumbers</code> are not updated. I thought that the <code>this.newNumbers = this.messages...</code> will execute because of my <code>share</code> operator is called. (Similar code in the mentioned above book works but they are using deprecated methods <code>publishReplay(1).refCount()</code> instead of my <code>share</code> operator. Could someone point me in the right direction - below is the code:</li>
  </ol>
  <pre class="lang-js prettyprint-override"><code>const initialMessages: number[] = [];
  
  @Injectable({ providedIn: 'root' })
  export class MessagesService {
    // `newNumbers` is a observable that contains the most up to date list of numbers
    newNumbers: Observable&lt;{ [key: string]: number }&gt;;
  
    newMessages: Subject&lt;number&gt; = new Subject&lt;number&gt;();
  
    // `messages` is a stream that emits an array of the most up to date numbers
    messages: Observable&lt;number[]&gt;;
  
    updates: Subject&lt;any&gt; = new Subject&lt;any&gt;();
  
    constructor() {
      this.messages = this.updates
        // watch the updates and accumulate operations on the messages
        .pipe(
          map((message) =&gt; {
            let retVal = initialMessages.concat(message);
            return retVal;
          }),
          share({
            connector: () =&gt; new ReplaySubject(1),
            resetOnError: false,
            resetOnComplete: false,
            resetOnRefCountZero: false,
          })
        );
  
      this.newMessages.subscribe(this.updates);
  
      this.newNumbers = this.messages.pipe(
        map((messages: number[]) =&gt; {
          const numbers: { [key: string]: number } = {};
          messages.map((n: number) =&gt; {
            numbers[n] = numbers[n] || n;
            console.log(n);
          });
          return numbers;
        })
      );
  
      this.messages.subscribe((value) =&gt; console.log(value));
    }
  
    addMessage(value: number): void {
      this.newMessages.next(value);
    }
  }
  </code></pre>