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
4 answers

Memoize for Observables in Typescript

I am looking for the best way of implementing an optimization for very expensive method that takes multiple parameters and returns an Observable. Is there an elegant way of doing it? What I am looking for is prettier version of this: class Example…
karruma
  • 768
  • 1
  • 12
  • 32
3
votes
2 answers

Typescript typing error with forkJoin

I'm experiencing a TypeScript type check failure when using the forkJoin operator form RxJS. This is the code in question: let products = this.http.get(productUrl, { headers: this.headers }) .map(response => response.json().data as…
Delmania
  • 812
  • 10
  • 20
3
votes
3 answers

Angular2 : How to redirect to the login page when observable subscription fails?

In the file auth-guard-service.ts, why is the call this.router.navigateByUrl('/login') not working, while the alert message is printed ? The other call in the other file (auth.service.ts) works correctly. auth-guard-service.ts import { Injectable } …
dng
  • 411
  • 1
  • 5
  • 18
3
votes
1 answer

How can I update Observable, which used in async pipe?

Problem is that: I have simple component, which renders some "history" of messages. When app is loaded, it makes POST-request, gets data and sets data to Observable like this this.messages$ = Observable.of(messagesAfterPOSTRequest); where public…
Eugene Shmorgun
  • 2,083
  • 12
  • 42
  • 67
3
votes
1 answer

RecyclerView scroll to top after back navigation if adapter's data set through RxAndroid

When I set adapter's data directly then the scroll position of the list is correct after I come back from detial fragment, but If I'm using RXAndroid to handle data then the scroll is always jump to the top. Here is an example about my…
Robertoq
  • 559
  • 1
  • 10
  • 21
3
votes
1 answer

Ionic storage "get" returns null only on the second call within method

I am facing a very strange issue with Ionic Storage. I have a method that reads a value from the storage and returns an a promise containing an object corresponding to that: private getAuthorizedOptions(): Promise { return…
Behrooz
  • 1,895
  • 4
  • 31
  • 47
3
votes
2 answers

Observable with Angular 4 , NgFor only supports binding to Iterables such as arrays

Yes, I see that other people get this error , I just don't quite get how to fix it in my code private _url = 'https://min-api.cryptocompare.com/data/pricemulti?fsyms=BTC,ETH,LTC,EOS,DASH&tsyms=USD' If I didn't have the return it does not crash…
user6824054
3
votes
1 answer

angularfire2 rxjs join observables from two tables with dynamic updates

So I have two tables. One of which is my user which stores blocks The other stores the data for these blocks. I am trying to combine these correctly so in my component I get a list of blocks with their data according to dataID - user - blocks …
3
votes
2 answers

Observable transformation

I'm very new to observables, this might be a silly question for others but I can't find a way to do it. How do I convert Observable> where T is a TypeScript class with property Id(string) into an Array? I want to convert the Id…
3
votes
2 answers

Making nested API calls in Angular

I need to make nested http calls in my angular app. First call returns the list of venues, then using each venue id i have to make multiple api calls to get details of each venue. Here is my code, service.ts GetResponse(){ return…
user7889681
3
votes
1 answer

Use Observable for a one time event

I have 2 functions ( for simplicity, open/close ): open(config){ ...do something this.watchForClosing = Observable.create(..?..) return this.watchForClosing } close(closeArgs){ this.watchForClosing.complete(closeArgs) } What i am…
29er
  • 8,595
  • 12
  • 48
  • 65
3
votes
1 answer

Converting AngularJS deffered promise to AngularX observable for JSOM

I am converting an AngularJS application to Angular 4 which gets some data from SharePoint. It is using the JSOM and for that the executeQueryAsync() method. I would like to get the data with executeQueryAsync() from the server and store it in an…
Florian Leitgeb
  • 15,657
  • 6
  • 31
  • 40
3
votes
1 answer

Why don't we need to subscribe to an observable here before converting it to a Promise?

My Service class contains code as : Service.ts //all imports are done @Injectable() export class Service{ constructor(private http: Http) { } getGoogle():Observable { console.log("Inside service"); return…
user8348978
  • 81
  • 1
  • 1
  • 7
3
votes
1 answer

Rxjs - Observable subscribe to watching one variable, completing on a change

i am trying to create an observable to watch a variable in my app, and as soon as the variable changes to null, all subscribers should be notified and completed. I was assuming the takeUntil property would work best but I seem to be doing something…
29er
  • 8,595
  • 12
  • 48
  • 65
3
votes
1 answer

Using zip() with a Maybe that may not emit a value

I'm trying to execute two Maybe at once and call a specific method once both are done. This works if both Observables return a value but in certain cases one might not emit an item thus calling only doOnComplete and not doOnSuccess. So if one of…
user3420815
  • 775
  • 9
  • 20