rxjs: switchMap and switchMapTo

 https://stackoverflow.com/questions/39108549/switchmapto-creates-observable-before-subscription

It is calling early because you are calling the function when you are building the stream.


switchMap takes a function which gets invoked when a new value comes from up stream. The result of that function is subscribed to as a new stream.


switchMapTo takes an Observable which is subscribed to for every value that comes from up stream. You are creating the Observable by invoking getTestStartTime$().


Use switchMap when the output depends on the value coming from upstream, and use switchMapTo when the actual upstream value is irrelevant and is only used as a signal for subscription.


Không có nhận xét nào:

Redirect www.example.com to example.com

 https://stackoverflow.com/questions/39303725/virtual-host-force-https-and-redirect-www-to-non-www-but-no-other-subdomains With the proper u...