rxjs

angular reactive form valuechanges with pipe. IS THIS A BUG ???

﹥>﹥吖頭↗ 提交于 2019-12-11 15:15:04
问题 Seems like pipe doesn't work with reactive form control valueChanges. i've prepared this https://stackblitz.com/edit/angular-vdeqrz so that you can reproduce the problem. type something in the text field. then type "boom" (without the quotes). after the error catch, the control does not work any more. you can verify typing something new on it after that. it does not detect any other input. if you refresh the page, then it works again. am i missing something here ? 回答1: This is not a bug.

rxjs - How to retry after catching and processing an error with emitting something

青春壹個敷衍的年華 提交于 2019-12-11 15:12:15
问题 I'm using rxjs v5.4.3 , redux-observable v0.16.0 . in my application, I'd like to achieve below: an user has auth token, and refresh token to regenerate auth token. the user requests with auth token. (by emitting REQUEST action) if it failed, request regenerating auth token with refresh token. if refreshed, emit TOKEN_REFRESHED action to update auth token, and do not emit REQUEST_FAILURE. if refreshing failed, emit REQUEST_FAILURE after refreshing(and updating auth token reducer), retry

How to compare actions data in Observable stream?

只谈情不闲聊 提交于 2019-12-11 15:08:59
问题 I'm using Redux and have problem with RxJs. Let's say that one action was fired 3 times (type: 'OPEN') during 2 secs. Action is sending some data to Redux state. First and third fired are bringing the same data, but second not. All of them have delays before coming to bring some effects. I want Observable to notice, that action 1 and action 3 have the same data and change the order of output. From 1, 2, 3 => 2, 3. The first one should be deleted because of action nr 3. const

Rxjs Scan with so many comas inside its function body?

随声附和 提交于 2019-12-11 14:57:10
问题 I have been looking at this code. https://www.learnrxjs.io/recipes/alphabet-invasion-game.html const game$ = combineLatest(keys$, letters$).pipe( scan < [string, Letters], State > ((state, [key, letters]) => ( letters.ltrs[letters.ltrs.length - 1] && letters.ltrs[letters.ltrs.length - 1].letter === key ? ((state.score = state.score + 1), letters.ltrs.pop()) : noop, state.score > 0 && state.score % levelChangeThreshold === 0 ? ((letters.ltrs = []), (state.level = state.level + 1), (state.score

Can RxJS Observables perform inter-process communication in an Electron app?

倖福魔咒の 提交于 2019-12-11 14:55:32
问题 For an Electron app, I was wondering, if we could instead of using the remote module to communicate between different Renderer Processes, use Observables. I have read that Renderer Processes and the Main process are completely different which would, the way I understand, restrict the usage of Observables. I am also not completely aware of the details of an Observable. So please, go easy on me :P 回答1: Per comment, I think there are some misreadings what Observable can do vs. can't do.

Observable of array, find index of value

泄露秘密 提交于 2019-12-11 14:48:59
问题 I'm writing an Angular app that gets a selection of stores from a service, as an Observable. When the user clicks a marker on the map, I want to get the index of the store in the array that lives inside the Observable. stores: Observable<Store[]>; ngOnInit() { this.stores = http.get<Store[]>('URL'); } onMarkerClick(event) { const geopoint = event.geopoint; //How can I get the index where store.geopoint === event.geopoint? } 回答1: For filtering the stores from the array you do: this

Angular: How to map JSON result from HttpClient request to class instances?

杀马特。学长 韩版系。学妹 提交于 2019-12-11 14:44:55
问题 I have the following code which seems wrong: public search(searchString: string): Observable<Array<ClientSearchResult>> { let params = new HttpParams().set('searchString', searchString); return this.http .get<Array<ClientSearchResult>>(this.searchUrl, { params: params }) .map((results: ClientSearchResult[]) => results.map((r: ClientSearchResult) => new ClientSearchResult(r))); } I know that the API is returning a JSON object which is not the same as an instance of my TypeScript class. However

Endless HTTP Stream Observable not emitting anything but data transferred

a 夏天 提交于 2019-12-11 14:32:20
问题 I've been digging an issue with Angular 4 and RxJS. Here is my code, the issue is, the http.post request Observable is not emitting anything to the next of the chain, the map() . The POST just get an endless response, it's a stream of Motion JPEG data. Now I have to deal with the data, say each 500KB transferred. My problem is that I cannot do anything with the data if the Observable not emitting anything. So how to make such angular HTTP feature emit to the next of the chain each chunk of

GroupBy for Observable<todo[]>

丶灬走出姿态 提交于 2019-12-11 14:04:30
问题 I'm retrieving a flat list of todo items from firestore in my angular app (ionic framework). The returned list is an Observable list and I'm using the async pipe to show the list in my template. This list of todo items has a due date, and I would like to do some custom grouping on it for displaying with group headers in my todolist app. the groups are: overdue (duedate < today) today (duedate == today) later (duedate > today) I'm experimenting with doing it in the view with some magic ngFor

RxJS groupBy and combineAll operators seem to omit output

不打扰是莪最后的温柔 提交于 2019-12-11 13:56:11
问题 When grouping output with the combination of .groupBy and .concatAll, some expected output is not generated. Sample code: var Rx = require('rx'); var source = Rx.Observable.from(['a1', 'a2', 'b1', 'b2', 'a3', 'a4', 'b3', 'b4']) .groupBy(function (item) { return item.substr(0, 1); }) .concatAll(); var subscription = source.subscribe( function (x) { console.log('Next: %s', x); }, function (err) { console.log('Error: %s', err); }, function () { console.log('Completed'); }); Actual output: $ node