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

Mike Feltman
  • 5,160
  • 1
  • 17
  • 38
blackHawk
  • 6,047
  • 13
  • 57
  • 100
  • 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](https://github.com/camsong/fetch-jsonp). then do: `Observable.formPromise(your_jsonp_promise)` which should work because `fetchJsonp` returns a promise. Good luck! – AIon Sep 30 '16 at 10:43

2 Answers2

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
Justin Levine
  • 265
  • 2
  • 16
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().

Ben Lesh
  • 107,825
  • 47
  • 247
  • 232