Because the code in the first snippet will generate a random number for each subscriber — so subscribers should see different numbers unless the source is published or shared.

The code in the second snippet generates a random number and the source then always emits that particular number.

RxJS core team member; front-end developer; mentor; speaker; open-source contributor

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store