LiveLoveApp logo

Solution - Share Operator

Solution

import { of } from "rxjs";
import { share, tap } from "rxjs/operators";

const source = of(1, 2, 3, 4, 5).pipe(
  tap((value) => console.log(`source: ${value}`))
);

/**
 * Replace the `connect()` operator with the `share()` operator.
 */
source
  .pipe(share())
  .subscribe(console.log);