observable

typescript error Expected 0 type arguments for get call

≯℡__Kan透↙ 提交于 2020-01-04 09:21:56
问题 I am getting typescript error Expected 0 type arguments, but got 1 for line that returns get call. What is wrong with my get call? public get(params: SummaryParams): Observable<Summary[]> { const uri = `${this.config.URLS.LOAD_SUMMARY}`; const params = new HttpParams() .set('startDate', params.startDate.toString()) .set('endDate', params.endDate.toString()) .set('userId', params.userId); return this.http.get<Summary[]>(uri, { params }); } 回答1: HttpClient has generic methods that can be used

typescript error Expected 0 type arguments for get call

六眼飞鱼酱① 提交于 2020-01-04 09:19:07
问题 I am getting typescript error Expected 0 type arguments, but got 1 for line that returns get call. What is wrong with my get call? public get(params: SummaryParams): Observable<Summary[]> { const uri = `${this.config.URLS.LOAD_SUMMARY}`; const params = new HttpParams() .set('startDate', params.startDate.toString()) .set('endDate', params.endDate.toString()) .set('userId', params.userId); return this.http.get<Summary[]>(uri, { params }); } 回答1: HttpClient has generic methods that can be used

Combine route and query parameters in Angular

不问归期 提交于 2020-01-04 09:17:25
问题 In Angular I have to process a route in the format /sections/{id}?filter={filter} i.e. I have a route parameter ( id ), and a query parameter ( filter ). Both parameters are optional, so all of these routes are valid and being listened to /sections/{id}?filter={filter} /sections?filter={filter} /sections/{id} /sections When handling a route I need to call a potentially expensive service, providing the parameters given. I can subscribe to both the params and queryParams of the route, but I

Where is Observable.Iterate() in Rx 1.0.10621.0/1.1.10621.0

岁酱吖の 提交于 2020-01-04 06:12:45
问题 I'm finding a few examples online of Reactive Extensions that require the use of Observable.Iterate(), but the package from NuGet, Rx version 1.0.10621.0 does not seem to include it. Unless I'm doing it all wrong? I assume that it was renamed, but I can't find any posts regarding that. Anyone know? 回答1: From Rx Forum: Wes Dyer: What about Observable.Iterate? Use the Observable.Create that takes a Func, Task> which works exactly the same as Iterate except that it uses async await to drive it.

Angular 2 : Chain Observables in Resolver

ぃ、小莉子 提交于 2020-01-04 05:20:07
问题 I am new to Angular2 and observables. I am trying to return the result of a chain of observables to my resolver and couldn't find an answer on SO. Everything works fine when I return only one observable, but fails when those are chained. I've simplified the code to calling consecutively twice the same test function : @Injectable() export class SwResolve implements Resolve<any> { constructor(private swService: SwService) {} resolve (route: ActivatedRouteSnapshot): Observable<MyObject> |

Return Observable inside the Promise

喜欢而已 提交于 2020-01-04 03:44:48
问题 Could you tell me how can I return Observable here? I have tried many ways. But no success yet. [ts] A function whose declared type is neither 'void' nor 'any' must return a value. deleteInvite(inviteId):Observable<HttpResponse<Object>> { this.getHttpHeader().then(headers => { return this.http.post(this.apiURL + "/deleteInvite", inviteId, { observe: "response", headers: headers }) }).catch(err => { console.error(err); }); } async getHttpHeader() { const accessToken = await this.getJWTToken();

How to do I show progress when using Reactive Extensions in C#

一个人想着一个人 提交于 2020-01-04 02:15:08
问题 Am using reactive extensions in C# to perform some calculations. Here is how my code looks like so far. I have tried to wrap the code around so that I can show progress while to executing a series of tasks within my Calculate method Here is the observable IObservable<ResultWithProgress<SampleResult>> Calculate(){ return Observable.Create<ResultWithProgress<SampleResult>>(obs => { var someTask = DoSomeTask1(); obs.OnNext(new ResultWithProgress(){Progress = 25, ProgressText ="Completed Task1"})

Read buffered response with Angular2/RxJS

牧云@^-^@ 提交于 2020-01-03 19:59:59
问题 I'm building a website that reads data from a backend. That data is computed on-the-fly and sent back to the client in a buffered manner. I.e. as soon as the first chunk is computed it is sent to the client, then it computes the next chunk and sends that to the client. This whole process happens in the same HTTP request. The client should not wait for the complete response to finish but handle each chunk by its own as soon as has been sent. Such responses can usually be consumed using the XHR

Read buffered response with Angular2/RxJS

倾然丶 夕夏残阳落幕 提交于 2020-01-03 19:59:50
问题 I'm building a website that reads data from a backend. That data is computed on-the-fly and sent back to the client in a buffered manner. I.e. as soon as the first chunk is computed it is sent to the client, then it computes the next chunk and sends that to the client. This whole process happens in the same HTTP request. The client should not wait for the complete response to finish but handle each chunk by its own as soon as has been sent. Such responses can usually be consumed using the XHR

posting object from angular 2 application to Web Api application (getting Unsupported Media Type)

半世苍凉 提交于 2020-01-03 17:05:12
问题 I could use some guidens, sending an object from my angular 2 application to the Web API. I know how to GET objects from the Web Api, to my angular 2 application, but can't seem to figure out how the post method works or even if I should use the http.post methodd. My angular 2 application has the following method: sendUpdatdReservation(updatedReservation: Reservation) { var result; var objectToSend = JSON.stringify(updatedReservation); this.http.post('http://localhost:52262/api/postbookings',