Usually we learn the function of a JS library, we will directly in the HTML with script to introduce the JS library to write some demo. When I was learning rxjs, I dropped it into the pit when I introduced it with a script tag.
From the 6.0.0-alpha.4 version, the global namespace (currently version 6.3.0) is RXJS, using the following method:
<script src= "Https://cdn.bootcss.com/rxjs/6.0.0-alpha.4/rxjs.umd.js" ></script>
<script>
/*
* HTTPS://GITHUB.COM/REACTIVEX/RXJS
* The global namespace for RXJS is RXJS
*/
const {Observable, Subject, Replaysubject, from, OF, range} = RXJS;
const {map, filter, switchmap} = rxjs.operators;
Range (1, 200)
. PIPE (
Filter (x = = x% 2 = = = 1),
Map (x = x + x)
)
. Subscribe (x = console.log (x));
</script>
The 6.0.0-alpha.4 version was previously (up to 6.0.0-alpha.3) and the global namespace was Rx, using the example:
<script src= "Https://cdn.bootcss.com/rxjs/6.0.0-alpha.3/Rx.min.js" ></script>
var observable = Rx.Observable.interval (1000);
var subscription = Observable.subscribe (x = Console.log (x));
SetTimeout (() =>{
Subscription.unsubscribe ();
},3000)
RXJS Global namespaces