Questions tagged [subject-observer]

Use this tag for questions related to an Observer for a Subject. Observers can subscribe to the subject to receive the last (or initial) value and all subsequent notifications.

119 questions
2
votes
1 answer

Which one is preferable : Rx-Subject or Android BroadcastReceiver

I have following project in Github : https://github.com/alirezaeiii/ExoPlayer-Service where I play music using ExoPlayer from Assets. When I click on Play/Pause button, I send a broadcast to Play/Pause ExoPlayer : public void playPauseClick(View…
Ali
  • 9,800
  • 19
  • 72
  • 152
2
votes
2 answers

Ngxs or behavior subject ,which to choose

I am going to make a front end application using Angular(latest version) which is dealing with bundle of microservices.Mainly it is the admin panel of a Payment gateway product. As I have worked with both NGXS state management and also subjects and…
Kalanka
  • 1,019
  • 2
  • 18
  • 31
2
votes
1 answer

Angular2, RxJS Subject http request - On error request wont fire again

I have an issue when receiving an http error response (422 validation error from backend). Once an http error response is received, I can't fire the request again (on button click). 1) I have a subject property, and I call…
Klemme
  • 83
  • 1
  • 8
2
votes
1 answer

Angular RXJS Observables or Subjects passing numbers Internally

what's the correct RXJS approach to passing numbers within an Angular 5 app (no API)? I've successfully passed a boolean with Subject : service : import {Injectable} from '@angular/core'; import {Subject} from 'rxjs/Subject'; @Injectable() export…
tatsu
  • 2,316
  • 7
  • 43
  • 87
2
votes
0 answers

Angular 2 view is not updating after the property was updated through a Subject

I'm setting the background-color of a div to be updated dynamically by assigning the style.background-color property like below..
{{ cellColor }}
In its typescript file I assigned a…
2
votes
1 answer

Reactive Observable Subscription: Stop Subscription and Renew Subscription

I have a Observable from BlockCollection that i use like a queue IObservable GetObservable() { _queue.GetConsumingEnumerable().ToObservable(TaskPoolScheduler.Default); } and subscribe to him: void…
2
votes
1 answer

RxJS .next() failing silently in Angular 2 App

I'm trying to write a basic angular 2 app, which uses the new version of RxJS -> "rxjs": "5.0.0-beta.6". I have followed the instructions from the cookbook, trying to make a notifications service, which any part of my app could call to show a…
Gilly Ames
  • 361
  • 4
  • 12
1
vote
2 answers

Unit Testing - Mocking a Subject using ng-mocks

I am trying to add unit tests to my angular component which is dependent on a service. The component is subscribing to a flag variable in the service. I am trying to use ng-mocks to mock the service using the MockProvider. And while trying to set…
1
vote
1 answer

Angular Subject: share only with some of the observers

Given a basic type export interface Item { id: string; } I define a class BackupClient with a Subject: export class BackupClient { private subject = new Subject(); private share(item: Item): void { this.subject.next(item); } …
DonFuchs
  • 371
  • 2
  • 14
1
vote
3 answers

When I update a Subject in NgOnInit it does not change other component associeted to be visible using ngIf

I hope you doing well. I have a loading component this component when is visible stays above all content with an loading circle and block all below elements to be touched during the loading process. To activate the loading component I need to change…
EACUAMBA
  • 461
  • 4
  • 8
1
vote
4 answers

Angular subject next not triggering subscribe

I searched here for answer but can't figure out why i'm facing this issue. I have no errors on my console. I want to emit a new value over a subject with its next method from a service. Then, in the component that use this service, I'm subscribing…
THaulbert
  • 25
  • 1
  • 4
1
vote
2 answers

Angular/RxJs - Calling next() on Observable in service after component was unsubscribe() cause ObjectUnsubscribedError

I have an Angular Service that defines a public Subject. Later under some condition, the service will call .next() on this Subject. In addition, I have an Angular component that .subscribe() to this Subject in it's ngOnInit() method, and call…
Gil Epshtain
  • 8,670
  • 7
  • 63
  • 89
1
vote
3 answers

Subject vs BehaviorSubject in Angular

I am passing data between 2 independent components using shared service. When I used a subject in my shared service, I could not see the subscribed data in html of the subscribed component but could see it in the console after subscribing. Whereas…
bhagya sri
  • 21
  • 1
  • 2
1
vote
3 answers

Process unknown number of observables in RxJS pipe

I make thousands of calls to my server but in order to avoid overloading, I have put in place a concurrency limit of 10 with RxJS: const calls = new Subject(); calls.pipe( mergeAll(10) ).subscribe(); while(int < unknown_number){ …
Nate
  • 7,606
  • 23
  • 72
  • 124
1
vote
3 answers

RxJs Subject getting multiple values on subscribe

I have a Subject in my Angular Service like this: private sub = new Subject(); sendSub(page: page) { this.sub.next(page); } getSub(): Observable { return this.sub.asObservable(); } In my parent component I have subscribed to…
prabas
  • 53
  • 1
  • 1
  • 9