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.
Questions tagged [subject-observer]
119 questions
3
votes
3 answers
Difference between Subject (being a special case of Observable) and Observable
According to the docs on Subject, it's a special case of Observable that lets all the observers share a common execution path. The example shows that each observer gets the same emitted values after it's subscribed to the source.
I'm not entirely…

Konrad Viltersten
- 36,151
- 76
- 250
- 438
3
votes
3 answers
Subject.subscribe not firing in ngOnInit
I have defined the subject in my service.ts
The onEditItem() in detail.component.ts passes the value of id in .next() and the Subject is subscribed in new.component.ts
But the subscription is not working. Subscription is done in ngOnInit in…

Sonali
- 51
- 1
- 6
3
votes
2 answers
Angular 6 - Behaviour Subject: get data to stay after refresh
I'm trying to pass data between course-detail component and course-play component. I used shared service and BehaviorSubject. The data is passing correctly to course-detail through the service, and when go to course-play html page through…

Ofir Sasson
- 673
- 4
- 16
- 39
3
votes
3 answers
Subject and Observable, how to delete item, filter() list and next()
I have a list of songs setup with Subject and Observable (shown with | async in view), and now I want to delete a song off the list, do some filter() and call next() on the Subject.
How and where do I filter? Right now I am doing getValue() on…

Jason Svendstorp
- 35
- 1
- 1
- 5
3
votes
0 answers
Blocking issue with Rx.NET Subject
In a WPF application, I am using Observable.Throttle() to limit the frequency of handling certain events coming in from the user interface.
This is the minimal simplified code as it pertains to the usage of Rx:
using System.Reactive.Linq;
using…

TeaDrivenDev
- 6,591
- 33
- 50
3
votes
1 answer
Does a Subject safely unsubscribe its subscribers when it completes?
If I have this class with a subject that emits a single value during its life:
export class MyClass {
myEmitter$: Subject = new Subject();
someMethod(){
this.myEmitter$.next();
this.myEmitter$.complete();
}
}
and then in…

user776686
- 7,933
- 14
- 71
- 124
3
votes
1 answer
Angular: Share data dynamically between components using RxJs/BehaviorSubject
I have two sibling components and showing side-by-side, let's say Component-A & Component-B.
Component-A have form controls, once user fill out the form, I need to perform some business logic and display the data into Component-B.
I have created…

Tanmay
- 325
- 1
- 5
- 13
3
votes
1 answer
Sharing Observable between Activities with RxJava and unsubscribing
I'm trying to implement a timer Observable that is Shared between the Activities of my application. I am making the implementation on a class that is a Dagger singleton which I inject in each Presenter of each different Activity.
I create the…

antonicg
- 934
- 10
- 24
3
votes
1 answer
Angular2 - Rxjs Subject run twice even after unsubscribing
I'm writing a desktop application using angular2 and electron and there is a download functionality.
My DownloadService is this
import {Injectable} from '@angular/core';
import {Subject} from "rxjs";
interface IQueueItem {
url:…

Sina Mirhejazi
- 324
- 2
- 16
3
votes
1 answer
How to create Observable from Subject without exposing the Subject to consumers in RxJs v5
I'm trying to return an observable from a function that uses Rx.Subject internally. Of course, as with any good API, the implementation details should be entirely abstracted from the consumer. However, using Subject.asObservable() it appears…

Adam Arthur
- 409
- 3
- 10
3
votes
1 answer
Angular 2.0.1 AsyncPipe doesn't work with Rx Subject
AsyncPipe works with BehaviorSubject, but I don't want to initialize my service with empty data, for this reason I use Subject intead.
The problem is NgFor and asyncPipe doesn't work with Subject, is it an issue?
This works:
Component:
export class…

Serginho
- 7,291
- 2
- 27
- 52
3
votes
2 answers
Overriding a method with polymorphic arguments
I have an interface (called Subject) that has the following method:
public void addObserver(Observer o);
I then have another interface that extends Subject called TimerSubject. This interface is a more specific version of Subject, used for timing.…

Ben Cracknell
- 271
- 3
- 11
2
votes
1 answer
Implementing Observers and Subjects using IObserver/IObservable
I want to create a class that can be used to represent a dynamically computed value, and another class that represents a value can be the source (subject) for these dynamically computed values. The goal is that when the subject changes, the computed…

cdiggins
- 17,602
- 7
- 105
- 102
2
votes
1 answer
Subject loses observer from array after first value emission. Angular RouteReuseStrategy table-edit form communications
My use-case is a list - detail view (master-detail, trying to move away from mastery termonology).
I edit a record from the table via routing to the edit form and passing the saved value between the routes/components via a data service using a…

Stephen Traiforos
- 21
- 3
2
votes
2 answers
How can I subscribe to a different service method using a conditional statement?
Can't figure out how to subscribe to the desired method of an Angular service depending on the conditional statement
// this.someService.someMethod depending on the conditional statement
.pipe(takeUntil(this.unsubscribe$))
.subscribe((items)…

Constantine Rafikov
- 87
- 7