Angular2: How to import rx-dom
Asked Answered
I

2

8

I want to use DOM in angular project like this

Rx.DOM.jsonpRequest

but DOM is not available on Rx which Im importing like this

import Rx = require('rxjs'); 

I also tried to import rxjs dom but error was can not find module, I installed rxjs-dom like this

npm install rx-lite-dom

but Im unable to import it so that I can DOM on Rx object

Intermeddle answered 3/6, 2016 at 6:30 Comment(1)
This comment is for people who want to install Rx.DOM for doing things like Rx.DOM.focus('#myInput'). Binding to dom events basically. But this is not the way. The way to do this in angular 2.0 is using Observable.formEvent('#myInput' 'focus'). I lost half a day trying to install rx-dom when was this better solution. As for jsonpRequest you can use this library. then do: Observable.formPromise(your_jsonp_promise) which should work because fetchJsonp returns a promise. Good luck!Prindle
Q
0

If you want access to the Rx variable, you can import it into an Angular project using:

import * as Rx from 'rx-dom';

You will then have access to the Rx variable, including the jsonpRequest as in:

Rx.DOM.jsonpRequest
Quadruple answered 25/9, 2017 at 12:51 Comment(0)
T
0

RxJS author here, rx-dom is an RxJS version 4 library related to rx... rxjs is version 5 and up.

For anyone that comes across this question, the answer is to just use any old JSONP library (or whatever) and convert it to an observable using defer, from, or just wrap what you'd normally do with it using new Observable().

Touchline answered 7/6, 2023 at 15:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.