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
1
vote
1 answer
Set Observable to complete, on a bool condition
I have to ensure an Observable to complete. It is observing stream data, which isn't in my focus to modify.
The stream data may not tick at all.
I came across using a subject member that I can use to manually complete the observable.
private…

deafjeff
- 754
- 7
- 25
1
vote
2 answers
Subject not being triggered when changing URL
My Application has the following app-routing.module.ts:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { PageNotFoundComponent } from './core/page-not-found/page-not-found.component';
const…

Gui Oliveira
- 155
- 2
- 9
1
vote
0 answers
Angular 9 Service with Subject.subscribe not working outside module
I made a simpler version of this question.
Service code:
import { Injectable, ElementRef } from '@angular/core';
import { Subject, Observable, BehaviorSubject } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class NotificationService…

Filip Witkowski
- 795
- 3
- 14
- 24
1
vote
2 answers
File upload progress not being updated in the observable or completed before the observable is ready
Below is a snippet of code that calls the function below. This is a process that allows people to drag and drop files from the system to the website. It displays a list of all the files with a progress bar as they are loaded. It works fine most…

Gary Dickerson
- 231
- 2
- 13
1
vote
2 answers
How can I use async pipe correctly to update template in angular 7
I have a service method which gets dummy data and returns an observable.
private dummySubject = new BehaviorSubject(null);
dummy$ = this.dummySubject.asObservable();
loadDummyData(id: string): Observable {
const BASE_URL =…

DevRight
- 345
- 1
- 6
- 25
1
vote
2 answers
Rxjs Behavior subject not updating data on the UI using ionic 4 and angular 7
I have an array of type BehaviourSubject defined and initialized in service and it gets updated upon editing it using another function. However, the results displayed on the UI are not of the new edited array but the changes are successfully applied…

Stephen Mutua
- 55
- 2
- 10
1
vote
0 answers
RXJS's Subject inside Function
Please, I need help with my code that does not work:
this.howToUseObservables().subscribe(ress => alert('in app ' + ress));
Why testSubject.next('test'); does not fire at all?
thanks
howToUseObservables(): Subject {
const testSubject:…

Abeer Abdel-samee
- 53
- 2
1
vote
1 answer
Angular 6 - Not able to subscribe to messages using subject
I am trying to communicate between 2 components.
Filter component is trying to send a message to result component through service http-service.
I am able to send message to service http-service but not able to receive message in result service even…

user1298426
- 3,467
- 15
- 50
- 96
1
vote
1 answer
RxJava PublishSubject+Debounce: the second item not emited
I want to use PublishSubject + debounce (in subscribe logic) for emit my items with delay. This is my code:
Subscription logic:
notificationSubject = PublishSubject.create()
notificationSubject
.debounce(300,…

Artem
- 4,569
- 12
- 44
- 86
1
vote
2 answers
Angular 6 RxJs: Trying to make an obj as observable to be use in other components
Service
mode: Subject = new Subject();
constructor(public http: HttpClient) {
this.setMode({ // defaults
admin: this.admins.includes(localStorage.getItem("email")),
edit: false,
dev: false
});
}
getMode()…

Omar
- 2,726
- 2
- 32
- 65
1
vote
1 answer
RxSwift trigger observable execution
I have a Subject observable representing the result of the network request that needs to be delivered to multiple subscribers.
I can use ReplaySubject of buffer 1 and publish() method. However, the network request gets executed only once.
I'd like…

Richard Topchii
- 7,075
- 8
- 48
- 115
1
vote
1 answer
How to wait for observables in template (using async pipe) to be subscribed to before running initialisation code?
I have a HTTP service which returns some information when a given item ID is passed to it. This is done through a Subject, which received the first piece of data in then ngOnInit method.
I then use the async pipe to display the data returned by the…

Kian Cross
- 1,818
- 2
- 21
- 41
1
vote
1 answer
Angular2:RxJS Subject not responding to events
I maintain a table which is generated from array of objects in which on click on a row would give an object which contain data of that one particular row.I needed to share it with all other components no matter it is a parent,child or sibling and…

Gayathri
- 1,776
- 5
- 23
- 50
1
vote
1 answer
RxJs Subject error - cannot read property 'subscribe' of undefined
In my service method that returns Observable I'm trying to notify the component via Subject that an action completed.
completed: Subject
constructor(private http: Http) {
}
loadItems(): Observable {
return…

andrey.shedko
- 3,128
- 10
- 61
- 121