rxjs5

Posting mutipart/form-data with RxJS ajax

别等时光非礼了梦想. 提交于 2019-12-11 05:53:00
问题 Is it possible to post multipart/form-data with RxJS Ajax observable? I tried to do so by setting Content-Type in ajax settings object like so. import { ajax } from 'rxjs/observable/dom/ajax'; let data = { ad = 'ad_id', image = <HTML5 File object> } let settings = { url: '/some-url', body: data, method: 'post', headers: { 'Content-Type': 'multipart/form-data; boundary=---------2e50046', ... } ... } And used ajax(settings) to post the form However, it does not seem to work when sent to backend

Is there an equivalent to RxJs<=4#ofArrayChanges in RxJs5

耗尽温柔 提交于 2019-12-11 05:28:10
问题 I am using Angular2 and I want to track changes in array,but there is only RxJs5,and seems it hasn`t such functionality. 回答1: There is no equivalent. The Object.observe proposal has been withdrawn from ES7, so there is little point in having ofArrayChanges or ofObjectChanges in RxJS 5. 来源: https://stackoverflow.com/questions/39181404/is-there-an-equivalent-to-rxjs-4ofarraychanges-in-rxjs5

Proper Use of Redux-Ovservable ajax http methods: put, delete, post

核能气质少年 提交于 2019-12-11 05:14:50
问题 I'm new to Redux and Redux-Observable. I'm having success in getting information from a rest API with GET and GET(ID), but I cannot get the Delete and Post to work. Sample code below that is issuing a GET request: [EPIC File] import { debounceTime, Observable } from 'rxjs'; import { ajax } from 'rxjs/observable/dom/ajax'; import ActionTypes from '../actions/ActionTypes'; import { receiveFeedBack, receiveDeleteFeedBackId, receiveFeedBackId } from '../actions/FeedBackActions'; export const

Notify from inner flatMap

谁说胖子不能爱 提交于 2019-12-11 04:22:55
问题 Here a quite complex sample: Main: this.runInstructionAndGetResult().subscribe({ next: val => console.log(`NEXT VALUE: ${val}`), error: val => console.log(`ERROR VALUE: ${val}`), complete: val => console.log(`COMPLETE`) }); Observables: public runInstructionAndGetResult(): Observable<string> { return this.runAnInstruction() .flatMap((data) => { console.info("flatMap of runAnInstruction:", data); return this.getInstructionExecutionStatusInPolling() .filter(data => data != "Polling") .take(1)

Typescript typing error with forkJoin

微笑、不失礼 提交于 2019-12-11 04:05:10
问题 I'm experiencing a TypeScript type check failure when using the forkJoin operator form RxJS. This is the code in question: let products = this.http.get(productUrl, { headers: this.headers }) .map(response => response.json().data as Product[]); let loans = Observable.of(loan); return Observable.forkJoin([products, loans]) .map(data => { let resultProducts = data[0] as Product[]; if (resultProducts.length > 0) { lead.Product = resultProducts.find(i => i.ID == productId); } lead.Loan = data[1];

combineLatest behaviour in Rxjs 5?

為{幸葍}努か 提交于 2019-12-11 03:52:02
问题 Looking at the definition of combineLatest Combines multiple Observables to create an Observable whose values are calculated from the latest values of each of its input Observables. or Whenever any input Observable emits a value, it computes a formula using the latest values from all the inputs, then emits the output of that formula. It's pretty clear to see that at each period of time / emission , the result at that emission is the combination of the latest emissions. If so , looking at this

Angular 5 & Rxjs: Wait for all subscription

◇◆丶佛笑我妖孽 提交于 2019-12-11 02:43:40
问题 I would like to wait for all my http request to be completed before doing something. Before Angular 5, I was using promises and Promise.All . With Angular 5 and the new HttpClient , I transformed my promises into observables. If I understand correctly, I now have to use forkJoin to replace the Promise.All . But this is a problem because forkJoin expect Observables as parameters, but I already subscribe to those in the code ngOnInit() { forkJoin([this.getTemplates(), this.getHistory()])

Observable.prototype.concatAll does not seem to yield expected result

杀马特。学长 韩版系。学妹 提交于 2019-12-11 00:34:04
问题 With this code in mind: const Rx = require('rxjs'); var i = 3; const obs = Rx.Observable.interval(10) .map(() => i++) .map(function(val){ return Rx.Observable.create(obs => { obs.next(val) }); }) .take(10) .concatAll(); obs.subscribe(function(v){ console.log(v); }); I would have expected the logged result to be something like: [3,4,5,6,7,8,9,10,11,12] That is, 10 values, starting with 3. However, all we get is just 3 Does anybody know why that would be? 回答1: concatMap will wait for the first

Angular 2 RxJS Observable: Retry except on 429 status

試著忘記壹切 提交于 2019-12-11 00:33:41
问题 I've composed my Observable (from an HTTP request) to retry on failure. However, I would like to not retry if the server responded with 429 Too many requests error. The current implementation retries twice, 1 second apart, no matter what. return this.http.get(url,options) .retryWhen(errors => { return errors.delay(1000).take(2); }) .catch((res)=>this.handleError(res)); errors is an Observable. How can I get the underlying Response object that caused the error? With it I can access the server

Subject and Observable, how to delete item, filter() list and next()

送分小仙女□ 提交于 2019-12-11 00:12:48
问题 I have a list of songs setup with Subject and Observable (shown with | async in view), and now I want to delete a song off the list, do some filter() and call next() on the Subject. How and where do I filter? Right now I am doing getValue() on Subject and passing that to next() on, well, Subject. This just seems wrong and circularish. I also tried subscribing to the Subject and getting the data that way, filtering it and calling next() inside subscribe() , but I got a RangeError. I could