I'm trying to create web custom ponents using plain js. I would like to use rxjs and observables to fetch json content from a REST endpoint that I am also creating using python pyramid. However, an error - 'TypeError: global is undefined' - is being thrown when I import rxjs.
import '/@reactivex/[email protected]/dist/global/rxjs.umd.js';
also tried:
import '.5.2/rxjs.umd.js';
I would like to NOT use npm at all.
I'm trying to create web custom ponents using plain js. I would like to use rxjs and observables to fetch json content from a REST endpoint that I am also creating using python pyramid. However, an error - 'TypeError: global is undefined' - is being thrown when I import rxjs.
import 'https://unpkg./@reactivex/[email protected]/dist/global/rxjs.umd.js';
also tried:
import 'https://cdnjs.cloudflare./ajax/libs/rxjs/6.5.2/rxjs.umd.js';
I would like to NOT use npm at all.
Share Improve this question edited Aug 18, 2019 at 13:47 ferd tomale asked Aug 18, 2019 at 13:22 ferd tomaleferd tomale 90310 silver badges24 bronze badges 1-
found out how. I was supposed to put the url into a script tag and then use it in the js file as:
js const { Observable, from } = rxjs;
– ferd tomale Commented Aug 18, 2019 at 14:12
2 Answers
Reset to default 14<script src="https://cdnjs.cloudflare./ajax/libs/rxjs/6.5.2/rxjs.umd.js"></script>
then:
const { Observable, from } = rxjs;
With NodeJS and plain JS:
<script src="node_modules/rxjs/dist/bundles/rxjs.umd.js"></script>
// And JS code sample...
thisworkStatus$ = rxjs.merge(
rxjs.of(null),
rxjs.fromEvent(window, 'online'),
rxjs.fromEvent(window, 'offline')
)
this.applicationStatus$ = new rxjs.BehaviorSubject(this.getApplicationStatus());