I'm in the process of learning RxJS and i constantly try many operators and combinations that i find interesting.
I'm learning form here: http://reactivex.io/documentation/operators.html and here.
I have an Angular2 rc4 CLI project - so i'm using Typescript. RxJS is : 5.0.0-beta.6
The problem:
I found that some operators are not present on the Observable.
For example: I want to create an observable that returns one by one key value pairs of an object: You can see how the implementation looks like, as i've taken it from here.
// Using Standard JavaScript
var obj = {
foo: 42,
bar: 56,
baz: 78
};
var source = Rx.Observable.pairs(obj);
var subscription = source.subscribe(
function (x) {
console.log('Next: %s', x);
},
function (err) {
console.log('Error: %s', err);
},
function () {
console.log('Completed');
});
// => Next: ['foo', 42]
// => Next: ['bar', 56]
// => Next: ['baz', 78]
// => Completed
But here is what my editor looks like:
no Intelisense for Observable.pairs()..
Based on this post i've aded the 2 imports:
import {Observable} from "rxjs/Rx";
import 'rxjs/Rx'; // import all operators and stuff. it's not good practice i know, but only for this example
And tryed to install more typings for rxjs than angular cli provides, but is not working:
typings install --save --ambient npm:rx/ts/rx.all.d.ts // Unable to resolve "npm:rx/ts/rx.all.d.ts" from "rx"
or
typings install rxjs // Unable to find "rxjs" ("npm") in the registry.
And aslo tryed to use:
import * as Rx form 'rxjs/Rx'
myObjProperties$ = Rx.Observable.pairs(myObj) // still doesn't work, same error.
And aslo, I can't explain why printing the Observable object to the console doesn't work.. I get a string-function
which is useless. No prototype stuff.
console.log('TheAllmightyObservable : ', Observable) // i get:
// TheAllmightyObservable : function Observable(subscribe) {
// this._isScalar = false;
// if (subscribe) {
// this._subscribe = subscribe;
// }
// }
I have the same problem with many other operators: ofObjectChanges, ofArrayChanges, ofWithSkeduler, pairs - some of them not that important - but it bugs me when i found one RxJs operator that is very useful, and i can't use it in angular2 CLI project.
Questions:
what angular2 has to do with RxJS ? (i'm missing the general picture i guess..) - is there a separate list of angular2-rxjs operators or RxJS is fully separated package, and can be used like Jquery for example? I mean no wired interference between the 2 - that i can't predict. (digest cycle related maybe?!)
where can i find a good list of all the RxJS operators available on angular2 - assuming that exists.
is this only a Typescript - typings problem? If so, how to install them in order to have all the operators which are available on the docs? If no typings are available, how to temporarily get rid of this
"no property/method found on x"
problem?
Thank you so much for taking the time to read and help me by finding a solution to this:)