O operador publish () devolve ConnectableObservable e precisa usar o método connect () para assinar os observáveis.
Sintaxe
publish()
Exemplo
import { interval,Observable } from 'rxjs';
import { filter, publish } from 'rxjs/operators';
var observable = new Observable(function subscribe(subscriber) {
try {
subscriber.next(Math.random());
} catch (e) {
subscriber.error(e);
}
});
const observable1 = publish()(observable);
const subscribe_one = observable1.subscribe(
x => console.log("Value from Sub1 = "+x)
);
const subscribe_two = observable1.subscribe(
x => console.log("Value from Sub2 = "+x)
);
observable1.connect();
Resultado