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

Angular 4 - intercept http request and resend after login

I have an HttpInterceptor which listens to specific JWT token events (token_expired, token_not_provided and token_invalid) that can happen at different times of the workflow. These events can happen when a user navigates to a different route OR…
dev7
  • 6,259
  • 6
  • 32
  • 65
3
votes
1 answer

Bridging result of a Promise to an Observable

Apologies in advance if asking a dumb question. I did a search and could not find the answer I was looking for. I need the value for index which is returned in the Promise to be passed to my Observable as an argument: deleteFavorite(token: string,…
3
votes
2 answers

*ngFor iterates of an observable. Filtering onInput should be possible. How?

A view lists entries using a *ngFor based on an Observable: view.html {{medicine.name}} …
Jem
  • 6,226
  • 14
  • 56
  • 74
3
votes
2 answers

RxJava Kotlin how to get separated objects from single observable

RxJava Kotlin flatmap don't return separated objects from splitted string. instead it returns List val source: Observable = Observable.just("521934/2342/FOXTROT") .flatMap{Observable.fromArray(it.split("/"))} .subscribe{Log.d(TAG,…
Denis Belfort
  • 51
  • 1
  • 4
3
votes
1 answer

How to clean up Rx Subscription and Observable to prevent memory leaks?

I'm working on a project that uses Rx Java subscriptions and observables frequently and I am very new to the concept. I was wondering what the best practice is for disposing of them. Currently I am just nulling out the subscriptions/observables in…
David Carek
  • 1,103
  • 1
  • 12
  • 26
3
votes
5 answers

How to return an Observable in angular 4?

I have this method inside a authProvider provider class: getUser() { return this.afAuth.authState.subscribe(user => { return user; }); } I would like to subscribe to it in a different class, something like:…
Patrioticcow
  • 26,422
  • 75
  • 217
  • 337
3
votes
2 answers

Angular 2 consecutive http requests

In my angular data service I am trying to make two http request, with the second request depending on data from the first request. The first request is working fine, but for some reason the second request is never hitting my backend server. I was…
xeroshogun
  • 1,062
  • 1
  • 18
  • 31
3
votes
1 answer

Not able to assign Reponse type object to Response type variable

I'm getting the following error. Argument of type 'Response' is not assignable to parameter of type 'Response'. Property 'body' is missing in type 'Response'. The code I'm running relies on observables. public register(reporter: Reporter):…
Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438
3
votes
0 answers

How to consume streaming response from SpringBoot service in Angular 4 using observables?

I've created a microservice that returns a response in form of a stream using StreamingResponseBody class. I want to consume this response in AJAX call using RxJS Observables in my Angular 4 application. Here is my controller: @RestController public…
3
votes
1 answer

Is there any better way to track subscriber changes?

Lets say we have a Client class with method to send messages to server queue. It is also subscribed to queue and server will send a notification back to all clients when it receives a new message from any of registered clients: public class Client…
dmkov
  • 334
  • 2
  • 11
3
votes
2 answers

Angular 4 HTTP Not Returning The JSON body

I have the following method in my Typescript! allPowerPlants(onlyActive: boolean = false, page: number = 1): PowerPlant[] { const params: string = [ `onlyActive=${onlyActive}`, `page=${page}` ].join('&'); const path =…
joesan
  • 13,963
  • 27
  • 95
  • 232
3
votes
1 answer

Merging Observable and take action when all subjects have emitted a value

I'd like to merge observables into one and then subscribe when ALL of the subjects have emitted a value. So far, I've tried Observable.merge and Observable.zip public A:Subject = new Subject(); public B:Subject = new Subject(); public…
PowerLove
  • 303
  • 8
  • 25
3
votes
1 answer

Return Observable of arrays from rxjs/Subject (Observable.from vs. Observable.of)

I am using WebSockets to communicate with backend WebApi. Everything is working fine, EXCEPT I cannot return my custom object from my service. I am using Angular 4.3.4 and rxjs 5.4.3. //ngInit from my component ngOnInit() { …
GamerDev
  • 2,006
  • 4
  • 24
  • 31
3
votes
1 answer

ActivatedRoute paramMap observable emits the value twice / firing twice - Angular 4

I'm having a problem with Angular 2/4 and getting a param(s) for the specific route. I did this like hundred times and never had problem like this, as you can see from the code I call paramMap on the route expecting it will be only run once, but…
Serjuice
  • 569
  • 4
  • 16
3
votes
1 answer

Angular services: best pratice for observables

I'm in the process of moving from the basics of Angular to learning more about best practices. I've started trying to adopt a more reactive approach lately, but there is one thing I can't find a good answer to by simply googling. Now, we can have…