Questions tagged [observable]

An observable is typically a programming construct that can be "watched" by other parts of the code, called the "observers". Different frameworks and programming languages have different implementations for observables, so this tag should typically be used in conjunction with others.

An observable is typically a programming construct that can be "watched" by other parts of the code, called the "observers". Different frameworks and programming languages have different implementations for observables, so this tag should typically be used in conjunction with others.

An observer may be any object that implements interface Observer. An observable object can have one or more observers. After an observable instance changes, an application calling the Observable's “notification” method causes all of its observers to be notified of the change by a call to their update method.

References

9527 questions
23
votes
1 answer

How do you catch with a pipe?

How do I do the following with lettable operators and pipe? this.httpClient .get(url) .map((res: any) => { const events = res.eventList; return events.map(e => new EventLogModel(e)); }) …
Nxt3
  • 1,970
  • 4
  • 30
  • 52
23
votes
4 answers

How to only execute an Observable if term is not null/empty?

I have the following code inside my constructor: this.searchResults = this.searchTerm.valueChanges .debounceTime(500) .distinctUntilChanged() .switchMap(term => this.apiService.search({ limit: this.searchResultsLimit, …
Fizzix
  • 23,679
  • 38
  • 110
  • 176
23
votes
3 answers

Angular 2 cache observable http result data

I have a service that fetches data via the HTTP service and returns an observable object. After the first call I would like to cache the result internally in the service, and once a new component will try to get the data it will take it from the…
Avi
  • 261
  • 1
  • 3
  • 6
23
votes
4 answers

Property '' does not exist on type 'Object'. Observable subscribe

I have just started with Angular2 and I've got an issue I cannot really understand. I have some mock data created as such: export const WORKFLOW_DATA: Object = { "testDataArray" : [ { key: "1", name: "Don Meow", source:…
0plus1
  • 4,475
  • 12
  • 47
  • 89
23
votes
2 answers

Angular2 Observable BehaviorSubject service not working

I'm trying to create my own observable service but after i get the initial data from the service, any updates to the service aren't propagated to any subscribers. Service looks like this: import { Injectable } from '@angular/core'; import {…
kjoetools
  • 528
  • 1
  • 6
  • 12
22
votes
3 answers

How to rethrow errors of HttpService call with NestJS?

I am using NestJS to essentially proxy a request to another api using the HttpService (an observable wrapped Axios library). For example: return this.httpService.post(...) .pipe( map(response => response.data), ); This works properly when…
Chaz
  • 3,232
  • 5
  • 19
  • 12
22
votes
1 answer

Observable usage pattern in Typescript

When an async service has no return value but I want to use Observables I'm inclined to use Observable. But I don't have meaning for this boolean value because the service either fails or succeeds and if it fails I want the Observable to be…
Halt
  • 2,924
  • 4
  • 22
  • 26
22
votes
6 answers

what triggered combineLatest?

I have a few observables. And I need to know which one triggered the subscribe. Observable.combineLatest( this.tournamentsService.getUpcoming(), this.favoriteService.getFavoriteTournaments(), …
AlexZvl
  • 2,092
  • 4
  • 18
  • 32
22
votes
7 answers

Angular 2 - Show loading-information when (observableData | async) is not yet resolved

just as the title says, I want to embrace the power of rxjs Observables. What I do now: // dataview.html
Loading data...div>
  • {{ d.value }}
//…
Alexander Ciesielski
  • 10,506
  • 5
  • 45
  • 66
21
votes
1 answer

RxJS / Angular Observables use 1 or multiple pipes?

Having the following (just a quick example): observable.pipe(map( s => s.anything )) .pipe(filter(t => t > 5)) .pipe(map( t => t+5)) .subscribe( XXX ) Why should I use 1 pipe instead? observable.pipe( …
user2992476
  • 1,536
  • 2
  • 17
  • 29
21
votes
2 answers

Observable forkjoin subscribe types

I'm making 2 API requests calls with typed responses, combining them into a single Observable.forkJoin. I want to get both results in different typed variables. var observableOrganization: Observable =…
Jorge Guerola
  • 2,072
  • 1
  • 16
  • 18
21
votes
5 answers

RxJS 1 array item into sequence of single items - operator

Given such observable Rx.Observable.of([1,2,3,4,5]) which emits a single item (that is an array), what is the operator that will transform this observable to a one that emits 5 single items (or whatever the array consists of)? The example is on…
ducin
  • 25,621
  • 41
  • 157
  • 256
21
votes
7 answers

Angular2 rxjs sort (observable) list of objects by an observable field

I want to sort a list of things by an observable field, but can't wrap my head around observables to get this working. Has somebody an idea how to achieve this? The initial situation is something like the following: Thing[] things; interface Thing…
sclausen
  • 1,720
  • 3
  • 15
  • 22
21
votes
8 answers

angular2 Observable Property 'debouceTime' does not exist on type 'Observable'

I use "angular2 webpack" and "angular2/form,Observable" , but met an error ,need help .. There is a custom form validator -- import {Observable} from 'rxjs/Rx'; import {REACTIVE_FORM_DIRECTIVES,FormControl, FormGroup, Validators} from…
Kery Hu
  • 5,626
  • 11
  • 34
  • 51
21
votes
7 answers

Observable fromArray

I currently have a problem with Angular2 and Observable object. I have a Component who calls a Service : a real one linked to an api and a fake one. The service linked to the API works well but when I use the fake one, I want to return an Array from…
intuix
  • 268
  • 1
  • 2
  • 8