RXJS Global namespaces

Source: Internet
Author: User
Tags script tag

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.