ReactiveX / rxjs

A reactive programming library for JavaScript
https://rxjs.dev
Apache License 2.0
30.7k stars 3k forks source link

Using RxJS5 straight from browser (ES5) #1274

Closed akauppi closed 8 years ago

akauppi commented 8 years ago

This seems to be possible, but is not really mentioned in the project README.md.

To use RxJS5 from a browser (global variables, no requirements management), use the UMD variant:

$ npm install @reactivex/rxjs

Then in HTML:

<script src="..pathto../Rx.umd.min.js"></script>

I believe in the transition from RxJS4 to RxJS5 I won't be the only one coming with a plain browser project. This would help in the transition, then eventually I might pick up packaging as well. All I suggest is adding a line to the README (can suggest a PR if this gets a preliminary go-ahead).

staltz commented 8 years ago

All I suggest is adding a line to the README (can suggest a PR if this gets a preliminary go-ahead).

I think that would work. I don't know why anyone would be against it.

PS: JSBin already supports adding RxJS 5, and the link they use is https://npmcdn.com/@reactivex/rxjs@5.0.0-alpha.8/dist/global/Rx.js

justinwoo commented 8 years ago

Here's a JSBin link if you just want it to work: http://jsbin.com/leyayi/1/edit?html,js,console

Uses the umd build of RxJS5 beta1: https://npmcdn.com/rxjs@5.0.0-beta.1/bundles/Rx.umd.js

benlesh commented 8 years ago

This seems to have been answered adequately. Closing for now. @akauppi if you feel your issue is still unresolved, please reopen.

ziaukhan commented 8 years ago

@blesh http://jsbin.com/leyayi/1/edit?html,js,console is running perfectly in chrome but in safari it is giving an error as show below. Same error with Beta 2.

screenshot 2016-03-14 20 07 32
benlesh commented 8 years ago

@ziaukhan Safari doesn't like your arrow function. Switching the JSBin mode to ES6/Babel solves the problem.

ghost commented 8 years ago

In JsBin, I got error "Rx.Observable.just is not a function" in Firefox & Chrome. JsBin example : http://jsbin.com/vunuta/edit?html,js,console

HTML : script src="https://npmcdn.com/@reactivex/rxjs@5.0.0-beta.7/dist/global/Rx.umd.js">

Typescript :

Rx.Observable.from ([1,2,3]).subscribe(x => console.log(x)); // Work Rx.Observable.just (99).subscribe(x => console.log(x)); // Fail Rx.Observable.return (99).subscribe(x => console.log(x)); // Fail

Tx

ghost commented 8 years ago

I found why, Operation return / just are replace by operator of in rxjs5. https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md

briosheje commented 6 years ago

For those wondering, the proper way to do so is:

  1. Clone the official repo
  2. run npm install
  3. Navigate to: /dist/global/
  4. Your file is rxjs.umd.js (or rxjs.umd.min.js).

Include it in your web project. BEWARE though: the major namespace (Rx) is undefined in the umd version, so instead of:

Rx.Observable.create

you should rather do:

var Rx = window['rxjs']; Rx.Obserable.create .

lock[bot] commented 6 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.