rxjs5

Produce a stream of values with data-driven delays in RxJS

末鹿安然 提交于 2020-01-05 04:15:06
问题 Given an array of objects which contain a message payload and time parameter like this: var data = [ { message:"Deliver me after 1000ms", time:1000 }, { message:"Deliver me after 2000ms", time:2000 }, { message:"Deliver me after 3000ms", time:3000 } ]; I would like to create an observable sequence which returns the message part of each element of the array and then waits for the corresponding amount of time specified in the object. I'm open to reorganising the data structure of the array if

Using observables in an Angular 2 template with *ngFor

梦想的初衷 提交于 2020-01-04 09:18:22
问题 I am unable to access a property of an object provided by the async pipe if I build the access chain using *ngFor. In the example below, suppose that Parking in the test line and the ?.[filter.propName] two lines beneath represent the same key on the same object. The test line will evaluate to true, but the checked property does not. Why? How do I access the propery when stamping these out with *ngFor? For example, if {{(compModel | async)?.Parking?.Garage}} === true I would expect {{

Other operator in calculation chain than combineLatest to avoid redundant calculations

自古美人都是妖i 提交于 2020-01-04 05:21:22
问题 I've successfully migrated a larger Excel calculation to JS using RxJS. Any input data is represented as an Observable and subsequent calculations are implemented with .map and .combineLatest when any Excel formula uses more than one input. This works great except for one problem. Here is a simplified example: Three inputs ( a$=1 , b$=2 , c$=3 ) are used in two different calculations ( $ab = $a+$b = 3 in the first, $bc = $b+$c = 5 in the second) as intermediate steps to calculate the final

Angular 2 - RxJS Switch Map Issue

女生的网名这么多〃 提交于 2020-01-03 13:35:29
问题 I'm trying to have an infinite scrolling section in my application. To achieve this I'm using this component to handle the scroll events and so on. When the scroll reaches the bottom of the div I'm calling a function to get more data. So far so good. To make this function more efficient I'm trying to wait a few seconds before the call is made as well as make sure that the data is processed properly. To do this I've been looking at the example shown on the Angular website that showcases a

Observable errors with Angular2 beta.12 and RxJs 5 beta.3

北慕城南 提交于 2020-01-03 08:53:12
问题 Hello, I am using Angular2 beta 12 running in VS2015. When I update to rxjs from 5.0.0-beta.2 to beta.3 I encounter a range of exceptions generally relating to my promises. E.g. Property map does not exist on type Observable<Response> Property share does not exist in type Observable<Response> Ambient modules declaration cannot specify relative module name Ambient modules cannot be nested in other modules or namespaces. Package.json { "name": "ASP.NET", "version": "0.0.0", "scripts": { "tsc":

Rate-limiting and count-limiting events in RxJS v5, but also allowing pass-through

烈酒焚心 提交于 2020-01-02 11:19:14
问题 I have a bunch of events to send up to a service. But the requests are rate limited and each request has a count limit: 1 request per second: bufferTime(1000) 100 event items per request: bufferCount(100) The problem is, I am not sure how to combine them in a way that makes sense. Allowing pass-through Complicating this further, I need to make sure that events go through instantaneously if we don't hit either limit. For example, I don't want it to actually wait for 100 event items before

How to resumeOnError (or similar) in RxJS5

老子叫甜甜 提交于 2020-01-02 10:32:50
问题 I would like to use the onErrorResumeNext feature of RxJS, i.e. to continue to receive events even if an error is received (instead of terminating). But I can see in the following doc that there is no correspondance in RxJS5: https://github.com/ReactiveX/RxJS/blob/master/MIGRATION.md. Is there a workaround to use such feature? Thanks! 回答1: I've been looking for that operator too! I came up with a solution for my needs that I hope will help yours. It's not the best solution most likely, but I

Observable.of turn async

风格不统一 提交于 2020-01-02 05:40:09
问题 I'm about to mock a http call wrapped into observable. My initial idea was to simply use Observable.of similar to Promise.resolve , but it does not seem to work as I expected: Rx.Observable.of('of1').subscribe(e => console.log(e)); console.log('of2'); Rx.Observable.from(Promise.resolve('from1')).subscribe(e => console.log(e)); console.log('from2'); <script src="https://npmcdn.com/@reactivex/rxjs@5.0.0-beta.6/dist/global/Rx.umd.js"></script> It seems that Observable.of runs synchronously while

RxJs Branching If Else Logic

前提是你 提交于 2019-12-31 04:32:08
问题 onSave() { // event handler const save$ = combineLatest(this.configData.data, this.layerService.layerData) .pipe( filter(([configData]) => !_.isEmpty(configData)), take(1), tap(_ => this.loadingService.showLoading()), map(data => this.createSaveConfig(data)), flatMap(dataJSON => this.saveService.save(dataJSON)), ).share(); const saveAndReload$ = save$.pipe( filter(_ => !this.savedId), pluck('savedId'), flatMap(savedId => this.saveService.getData(savedId)), tap(reportData => this

Type Error: observable.of is not a function - angular-cli@1.6.3 - rxjs@5.5.x - angular5

末鹿安然 提交于 2019-12-31 04:09:11
问题 After upgrading to angular-cli@1.6.3 and converting all the RxJS imports, methods, and operators to the new >5.5 form, I get a type error at run-time saying that Observable.of is not a function. The same error happens with all the methods that are defined as a member of an extension of Observable , for example, Observable.fromEvent . On the other hand, the methods that are defined as stand alone functions, like Observable.combineLatest run properly despite the compiler warns that them don't