observable

How do I use the RXJS selector function in the Observable.bindCallback method?

自作多情 提交于 2020-01-17 06:00:33
问题 I believe that to get two params properly mapped back to the callback when using Observable.bindCallback method you have to use the "selector" function, but I cannot find documentation that explains how to do this. I may have a misunderstanding of what the selector function does, but it still should be documented. http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#static-method-bindCallback function testLogin(username, password, callback){ // ... callback(param1, param2); }

Filestream to RX throwing InvalidOperationException

和自甴很熟 提交于 2020-01-16 19:05:29
问题 I have set up a filewatcher to create me an observable stream of ticks whenever a file changes. This is then used as the trigger to start another repeated observable sequence that then reads the updated file contents from an open stream. The problem I have is if the file updates happen in large batches in quick succession, the code throws an InvalidOperationException with the message The stream is currently in use by a previous operation on the stream. Stack trace at System.IO.StreamReader

EventEmitter in angular services, good or bad?

浪子不回头ぞ 提交于 2020-01-16 18:09:28
问题 I was using EventEmitter and @Output in Angular services, today one of the coleagues mentioned it's not a good practice. I found this post mentioning it's a bad practice and it seems mostly is personal opinion, and this answer is mentioning it's OK to use it. I couldn't find any official document about it, so if somebody knows an official answer for it please post. Official doc about EventEmittter 回答1: I was using EventEmitter and @Output in Angular services, today one of the coleagues

Angular 6: subscribe does not exist on type void

醉酒当歌 提交于 2020-01-16 17:08:49
问题 I want to display success messages to user after submitting a form. form works perfectly when it come to submit the data but the flash message is not displayed and I get error: subscribe does not exist on type void Here is what I have done , Html: <form [formGroup]="angForm" novalidate> <div class="form-group"> <label class="col-md-4">Comment author</label> <input type="text" class="form-control" name="author" formControlName="author" #author /> </div> <div *ngIf="angForm.controls['author']

Angular 6: subscribe does not exist on type void

狂风中的少年 提交于 2020-01-16 17:08:31
问题 I want to display success messages to user after submitting a form. form works perfectly when it come to submit the data but the flash message is not displayed and I get error: subscribe does not exist on type void Here is what I have done , Html: <form [formGroup]="angForm" novalidate> <div class="form-group"> <label class="col-md-4">Comment author</label> <input type="text" class="form-control" name="author" formControlName="author" #author /> </div> <div *ngIf="angForm.controls['author']

Combining 'n' Observables of the same type (RxJava)

时光怂恿深爱的人放手 提交于 2020-01-15 07:46:37
问题 I have a code flow that generates an Iterable of Observables of the same type. I then go through them all, combining them and returning the result as an Observable. At the moment I'm using zip with a FuncN, which seems horrible and I think I've missed the point somewhere. Here's an example that uses a Map, it's obviously nonsense but you get the idea. final ImmutableList.Builder<Map<String, Object>> observables = ImmutableList.builder(); for (String key: keys) { if (someTest(key)) {

Why Observable.race not working if one of observable stop emit events?

主宰稳场 提交于 2020-01-15 04:54:17
问题 I'd like to implement websocket reconnect in webapp if internet connection is lost. In order to detect that internet is lost I use ping-pong approach, which means that I send from client ping-message and server returns me pong-message. When webapp loaded I send init ping message and start to listen a reply on socket some kind of this: this.websocket.onmessage = (evt) => { try { const websocketPayload: any = JSON.parse(evt.data); if (websocketPayload.pong !== undefined && websocketPayload.pong

Why Observable.race not working if one of observable stop emit events?

对着背影说爱祢 提交于 2020-01-15 04:54:06
问题 I'd like to implement websocket reconnect in webapp if internet connection is lost. In order to detect that internet is lost I use ping-pong approach, which means that I send from client ping-message and server returns me pong-message. When webapp loaded I send init ping message and start to listen a reply on socket some kind of this: this.websocket.onmessage = (evt) => { try { const websocketPayload: any = JSON.parse(evt.data); if (websocketPayload.pong !== undefined && websocketPayload.pong

Angular 5 subscribe and unsubscribe Observable

送分小仙女□ 提交于 2020-01-14 19:50:51
问题 I have to get datas from two subscribe but I get always data of the first one. I have a data shared service : import { Injectable } from '@angular/core'; import { BehaviorSubject } from 'rxjs/BehaviorSubject'; @Injectable() export class DataService { private source = new BehaviorSubject<any>(''); data = this.source.asObservable(); constructor() { } update(values: any) { this.source.next(values); } } Before leaving search component, I call update method. Now, I'm on the results component. I

How to return string instead of Observable with @angular/http

社会主义新天地 提交于 2020-01-14 19:05:07
问题 I am hooking Angular 4 with .net core WEB API. The Web API is returning a CustomerName in string based on the Id passed in. This is the service method in Angular 4. I understand that angular/http must return an Observable because it is an Async call. But how do I return a string instead? or how do I access the data within the Observable object from the calling method? getCustomerName(id: number): Observable<any>{ return this._http.get(this.baseUrl + 'api/getCustomerName/' + id ) .map(