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
0
votes
1 answer
how to keep only one parameter in a subject?
from a controller I input a parameter to a subject
selectImport(event){
this.importacionService.onChildSelectImportChanged.next(event);
}
and from my component importacion.component.ts I subscribe to this…

Luis Ruiz Figueroa
- 2,537
- 3
- 18
- 23
0
votes
2 answers
Notify other components when a particular key is changed in localStorage - Angular
My question is quite general. I want to watch for localStorage changes in angular but every key in localStorage need to be watched separately.
For example, I have some products list in localStorage at some key _products_ let's say, which stores an…

Gagandeep Singh
- 31
- 6
0
votes
1 answer
How to use Observables for inter-component communication
I am using Observables and Subjects from Rxjs to communicate between two components, Here is the service part:
import {
Injectable,
EventEmitter,
Output
} from '@angular/core';
import {
HttpClientModule,
HttpClient
} from…

Raghav
- 31
- 4
0
votes
3 answers
select on change angular implementation?
angularjs has a built in directive called onchanges which would listen to changes in a select or whatever and allow you to execute a function upon a change.
How I wish this was so in angular. Currently I am better understanding ngmodel and seeing…
user6781560
0
votes
1 answer
RXJS: Single Observable from dynamically created Observables
I am trying to create an observable (fixedObservable here) which will be fed by multiple dynamically created observable over time. Whenever a subscription is made than the subscriber should get the most recent value from the fixedObservable.…

rohit anand
- 286
- 3
- 5
0
votes
1 answer
Angular2 router doesn't change component
I have 1 component that I want to reuse for different router links there routes look like:
{ path: '', component: OddComponent },
{ path: 'sport/:id', component: OddComponent },
{ path: 'sport/:id/category/:categoryid', component: OddComponent…

Exploit
- 108
- 1
- 9
0
votes
0 answers
Rx-js. Buffering, caching, etc. in a subject
I have a subject that wraps a WebSocket (https://github.com/Reactive-Extensions/RxJS-DOM/blob/master/doc/operators/fromwebsocket.md) and I want to buffer messages received by the WebSocket. I've looked at…

vicaba
- 2,836
- 1
- 27
- 45
0
votes
1 answer
Generic Subject class Observor Pattern
I have been giving the following problem to solve. Make a generic Subject class (referring to Observor Pattern) such that it can accept any data type( primitive or user type). The register, remove and notify functions are also required to be…

Pranav Kapoor
- 1,171
- 3
- 13
- 32
-1
votes
1 answer
Why can subscribe be called on subject even after it is completed?
As per most of the blogs we don't need to explicitly unsubscribe the subjects once we call complete. I tried to subscribe the subject after calling complete on it. The complete call back was still executed.
let s = new…

Shubham
- 95
- 13
-1
votes
2 answers
Changes made in .subscribe() method not reflected out of it or in the template
I am using a Subject to add edit functionality to a basic phonebook app.
The changes that I make to component class variables inside of the subscribe callback are not reflected out of it or in the template.
I have tried the solutions listed in the…

Simran Makhija
- 1
- 1
- 2
-1
votes
1 answer
cannot call .next on Observables
I am sharing data across two sibling components using an injectible. In my injectible I am using an observable like this:
@Injectable()
export class DatasService {
message: Observable = new Observable();
changeMessage(){
…

Ankan Kumar Giri
- 243
- 1
- 3
- 12
-1
votes
2 answers
Generic Observer - Casting problems
I'm trying to make a generic observer pattern, modeled after a headFirst Design Patterns example. I get an error at the line marked with ??? below.
ERROR message says : The method registerObserver(Observer) in the type Subject is not applicable for…

AchillesVan
- 4,156
- 3
- 35
- 47
-2
votes
3 answers
Angular - Why ngOnInit is called every time i emit a new value?
I have a Subject called refreshSubject$ inside my service.
private refreshUsers$ = new Subject();
He is emitting a new value every time the user is added.
saveUser(user: User[]) {
return this.http.post(this.url, user)
…

Hugo Seleiro
- 2,467
- 5
- 26
- 39
-2
votes
2 answers
Why am I not able to subscribe to an observable from a different module(while setter also works) in Angular
I am trying to work across modules - I have written a service in a module
sharedService
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class SharedService {
private…

Venomoustoad
- 1,203
- 1
- 14
- 38