0

I have rxjs v6 from npm. I want to use it as part of a import using ES6 modules in the browser (Chrome v71)

From what I can see from here https://github.com/ReactiveX/rxjs and my general mucking about, it looks like I can't use it as part of an import.

Is there something small I can wrap it (thinking the CDN bundle) in to allow me to use it as part of the ES6 module system without the need for something like Webpack?

Cheetah
  • 12,515
  • 28
  • 93
  • 167
  • what do you mean? and what does wepack has to do with it? Even if you see in the doc you have posted, they show that you can do it even with es6 imports syntax: `import { range } from 'rxjs'; import { map, filter } from 'rxjs/operators';`. I use it every day with es6 module imports syntax – quirimmo Jan 21 '19 at 22:31
  • He may need this `import Rx from 'rxjs/Rx'`. – yujinpan Jan 22 '19 at 01:37
  • Related, presumably: https://github.com/ReactiveX/rxjs/issues/4416 – cartant Jan 22 '19 at 07:50
  • Sorry all, yes I meant in the browser. @cartant - that is exactly the issue I'm referring to. – Cheetah Jan 22 '19 at 08:27

1 Answers1

0

https://github.com/ReactiveX/rxjs#cdn

CDN
For CDN, you can use unpkg:

https://unpkg.com/rxjs/bundles/rxjs.umd.min.js

The global namespace for rxjs is rxjs:

const { range } = rxjs;
const { map, filter } = rxjs.operators;

range(1, 200).pipe(
  filter(x => x % 2 === 1),
  map(x => x + x)
).subscribe(x => console.log(x));

Jacek Pietal
  • 1,918
  • 1
  • 17
  • 27