reactive-extensions-js

Can I observe additions to an array with rx.js?

怎甘沉沦 提交于 2019-11-29 11:30:48
问题 fromArray Rx wiki on github coffee> rext = require 'rx' coffee> arr = [1..5] [ 1, 2, 3, 4, 5 ] coffee> obs = rext.Observable.fromArray(arr) { _subscribe: [Function] } coffee> obs.subscribe( (x) -> console.log("added value: " + x)) added value: 1 added value: 2 added value: 3 added value: 4 added value: 5 { isStopped: true, observer: { isStopped: true, _onNext: [Function], _onError: [Function: defaultError], _onCompleted: [Function: noop] }, m: { isDisposed: true, current: null } } coffee> arr

rxjs flatmap missing

断了今生、忘了曾经 提交于 2019-11-28 22:17:10
I try to chain multiple rx.js observables and pass the data. Flatmap should be the fitting operator but with an import of import { Observable } from 'rxjs/Observable'; it is not found: Error TS2339: Property 'flatmap' does not exist on type 'Observable<Coordinates>' Version 5.0.0-beta.6 of rx.js is used. public getCurrentLocationAddress():Observable<String> { return Observable.fromPromise(Geolocation.getCurrentPosition()) .map(location => location.coords) .flatmap(coordinates => { console.log(coordinates); return this.http.request(this.geoCodingServer + "/json?latlng=" + coordinates.latitude +

Angular2 RxJS getting 'Observable_1.Observable.fromEvent is not a function' error

℡╲_俬逩灬. 提交于 2019-11-28 19:32:44
问题 I'm using AngularJS 2 Beta 0 and I'm trying to create an RxJS Observable from an event on a window object. I believe I know the formula for capturing the event as an Observable in my service: var observ = Observable.fromEvent(this.windowHandle, 'hashchange'); The problem is that every time I try run this code, I get an error stating that 'fromEvent' is not a function. Uncaught EXCEPTION: Error during evaluation of "click" ORIGINAL EXCEPTION: TypeError: Observable_1.Observable.fromEvent is not

RxJS Continue Listening After Ajax Error

可紊 提交于 2019-11-28 19:23:46
RxJs stops listening to click events when an inner observable errors (Ajax request). I'm trying to figure out how to keep the event listener hooked to the button click event and gracefully handle the inner ajax error. Here is my example code and a link to plunkr var input = $("#testBtn"); var test = Rx.Observable.fromEvent(input,'click'); var testAjax = function() { return Rx.Observable.range(0,3).then(function(x){ if(x==2)throw "RAWR"; //Simulating a promise error. return x; }); } test.map(function(){ return Rx.Observable.when(testAjax()); }) .switchLatest() .subscribe( function (x) { console