最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ReactiveXRxJS 5 in the browser without any loaders? - Stack Overflow

programmeradmin3浏览0评论

How do you load RxJS in an old javascript application which does not use any loaders?
For RxJS 4.x I could simply do it like this:

<script src="//cdnjs.cloudflare/ajax/libs/rxjs/4.0.7/rx.lite.min.js"></script> 

What about RxJS 5? Their documentation assumes that you are using some kind of loader that will take care of everything, but for the intermediate step for legacy application when there is no loader, just files packed at build time?

They also mention ability to create your own bundle by including only the functions you use for "size-sensitive bundling" which sounds great.
So should i just create an entry point file and then add it to my build process and use some kind of tool (browserify/gluejs/webmake) to build everything into a single file that as in RxJS4 would expose Rx (or simply Observable) as global variable?, eg:

// run this through some tool to make it available in browser simply as Observable
var Observable = require('rxjs/Observable').Observable;
require('rxjs/add/operator/map');
exports=Observable

How do you load RxJS in an old javascript application which does not use any loaders?
For RxJS 4.x I could simply do it like this:

<script src="//cdnjs.cloudflare./ajax/libs/rxjs/4.0.7/rx.lite.min.js"></script> 

What about RxJS 5? Their documentation assumes that you are using some kind of loader that will take care of everything, but for the intermediate step for legacy application when there is no loader, just files packed at build time?

They also mention ability to create your own bundle by including only the functions you use for "size-sensitive bundling" which sounds great.
So should i just create an entry point file and then add it to my build process and use some kind of tool (browserify/gluejs/webmake) to build everything into a single file that as in RxJS4 would expose Rx (or simply Observable) as global variable?, eg:

// run this through some tool to make it available in browser simply as Observable
var Observable = require('rxjs/Observable').Observable;
require('rxjs/add/operator/map');
exports=Observable
Share Improve this question asked Mar 11, 2016 at 21:41 gerasalusgerasalus 7,7076 gold badges48 silver badges67 bronze badges 1
  • see the working plunkr here plnkr.co/edit/PUG3g7dfTbQjPyIgGLzh?p=preview its using Rxjs5 – FarazShuja Commented Aug 16, 2016 at 14:54
Add a ment  | 

1 Answer 1

Reset to default 10

As same as RxJS 4, RxJS 5 also provides umd builds via cdn can be embeded without requiring any module loader like

<script src="https://npmcdn./@reactivex/[email protected]/dist/global/Rx.umd.js"></script>

then Rx will be global variable you can access anywhere.

You may refer CDN hosted build description at https://github./ReactiveX/rxjs#cdn .

发布评论

评论列表(0)

  1. 暂无评论