import { ReplaySubject , Subject , fromEvent } from "rxjs" ; returns export function watchDocument ( ) { const document$ = new ReplaySubject < Document > ( 1 ) ; fromEvent ( document , "DOMContentLoaded" , { once : true } ) . subscribe ( ( ) => document$ . next ( document ) ) ; return document$ ; }