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
3
votes
1 answer

Filter observable array by object property

I currently have an array of observables which I'm iterating over using an *ngFor loop with the async pipe. I would like to filter the observables by a property value on the object, e.g Original array: [{ name: test1, type: type1}, { name:…
Michael B
  • 153
  • 4
  • 15
3
votes
1 answer

Angular2 Observable not binding correctly

I'm working on implementing a search functionality via Angular2/TypeScript. I'm having some trouble binding the search items returned to the view however. My component is this: import { Component } from '@angular/core'; import { SearchService } from…
docaholic
  • 613
  • 9
  • 29
3
votes
0 answers

Observable that retries only when a condition is met

I want to resume a sequence only under certain condition. I have this Observable: Observable .Defer(() => Observable.FromAsync(SomeAsync)) .Retry(); The condition: The observable should retry only when it receives an CustomException with a…
SuperJMN
  • 13,110
  • 16
  • 86
  • 185
3
votes
1 answer

Angular2 making multiple requests using rxjs subscribe

I have an angular2 app that adds or removes items from a multiple select box and sends each item to a remote api individually to be added to be processed in the database. The following method sends the request to the server and gets a response as…
Daryl1976
  • 675
  • 2
  • 8
  • 20
3
votes
1 answer

AngularFire .subscribe => console.log returning undefined after use of map or flatMap

I'm pretty new to AngularFire, Firebase, rxjs etc.. Can anyone tell me why the following returns 'undefined' from console.log? this.af.database.object('/teams/' + this.id) .map((data) => { data.teamName = Teams[data.team]; …
3
votes
2 answers

Getting updated values from Observable's subscription

I have noticed something about Observables in Angular 2 that I cannot explain and hope a good sould sheds light on me. My understanding was that when subscribing to an Observable you have basically two strategies to consume the value it…
user776686
  • 7,933
  • 14
  • 71
  • 124
3
votes
2 answers

why do we need subscriber method :Angular2

I am having hard time understanding Angular2 Http(Observable) methods: Here is my code: login(username:string,password:string) { let headers = new Headers(); this.createAuthorizationHeader(headers,username,password); return this.http …
lesnar
  • 2,400
  • 7
  • 41
  • 72
3
votes
4 answers

Get data once from 2 observables

I have 2 observables, and I need to get each observable data only one time. What I did is subscription inside a subscription, although they can be executed in the same time (in parallel). let table = this.af.database.object('tables'); …
TheUnreal
  • 23,434
  • 46
  • 157
  • 277
3
votes
1 answer

Angular 2 TS object array only defined while subscribed to service

I'm in the process of learning Angular 2 using TypeScript. So far I've written a little API service that uses HTTP get method to feed me json data using observables. Everything is working fine, I can use the data in my view, I can also use the data…
Robin
  • 51
  • 3
3
votes
1 answer

Concat Observables

I have some function to work with DB: setupData(param) { return Observable.create((observer) => { this.db.executeSql('SELECT .... ?', param).then(() => { console.log('DB QUERY DONE'); observer.complete(); …
Wishmaster
  • 1,102
  • 14
  • 20
3
votes
1 answer

Conditionally choose observable in RxJS

I would like to know how to create a new observable that will return one of two other observables based on if the first observable is empty (without calling the second observable by default). Eg: // scenario 1 let obs1 = Observable.empty(); let…
TimS
  • 1,113
  • 7
  • 10
3
votes
1 answer

Start stream when another Observable emits its first value

I have two observables, one from key press events and another from ajax requests. I want the second stream to start when the first stream emits its first value. var input$ = Rx.Observable.fromEvent( input, 'keydown') …
Avraam Mavridis
  • 8,698
  • 19
  • 79
  • 133
3
votes
1 answer

Subjects created with Subject.create can't unsubscribe

I have a subject that is responsible for subscriptions to certain observable: var timer$ = Rx.Observable.timer(1000, 2000); When the subject is linked to the subject like that var timerSubject = new Rx.Subject; timer$.subscribe(timerSubject); var…
Estus Flask
  • 206,104
  • 70
  • 425
  • 565
3
votes
4 answers

Replacing jQuery's get with something that uses the real Promise / Observable API

We have an Angular app. It uses Http from @angular/http. For easier development of services and functionality not related to UI, I'd like to use something else for HTTP requests, since using Angular's brings in a lot of dependencies and needs a…
Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277
3
votes
0 answers

Are subjects/ observables good to share async data between components (pages) in Angular 2

Lets say we have: Array of chat rooms Each room has an array of messages Rooms and messages in them are changed asynchronously via WebSockets. The best way to solve it in "Angular2 way" was via ReplaySubject Delegation: EventEmitter or Observable…
user3468806
  • 313
  • 4
  • 11
1 2 3
99
100