Skip to content

Instantly share code, notes, and snippets.

@cartant
Last active March 31, 2019 04:23
Show Gist options
  • Save cartant/ebd93eac1c49fece5fa0c737ff4a0c05 to your computer and use it in GitHub Desktop.
Save cartant/ebd93eac1c49fece5fa0c737ff4a0c05 to your computer and use it in GitHub Desktop.
import { concat, ConnectableObservable, of, race, timer } from "rxjs";
import { delay, mapTo, publish } from "rxjs/operators";
const source = of(42).pipe(delay(100));
const published = source.pipe(
publish()
) as ConnectableObservable<number>;
const composed = race(
published,
concat(timer(10).pipe(mapTo(54)), published)
);
composed.subscribe(value => console.log(value));
published.connect();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment