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
Getting current state in ngrx
Here is the solution for getting the current state in ngrx. The example is simple - you just use take(1). But in rxjs documentation for take it says:
Returns a specified number of contiguous elements from the start of an
observable sequence
How…

jur
- 513
- 4
- 12
1
vote
1 answer
Angular2: rxjs Subject in Angular2 child-parent component interaction
I want to manually subscribe to an event emitted by a directive, which, by design, should be available to multiple components of my application. At the moment the structure looks like this:
AppComponent
Draggable.Directive (uses an attribute of a…

pop
- 3,464
- 3
- 26
- 43
1
vote
1 answer
run PublishSubject on different thread rxJava
I am running RxJava and creating a subject to use onNext() method to produce data. I am using Spring.
This is my setup:
@Component
public class SubjectObserver {
private SerializedSubject safeSource;
public…

ameet chaubal
- 1,440
- 16
- 37
1
vote
2 answers
FlatMap and subjects - how to avoid duplicating subscribers?
Let's say I have the following code:
BehaviorSubject subject = BehaviorSubject.create();
BehaviorSubject subject2 = BehaviorSubject.create();
subject.
doOnNext(number -> subject2.onNext(number)).
flatMap(number ->…

Alexander Woodblock
- 497
- 9
- 31
1
vote
1 answer
Why onNext of Subject is unsolved?
In Angular2. When I call onNext on a Subject, it shows unsolved. rx is correctly imported.
import { Subject } from 'rxjs/Subject';
...
private _subject = new Subject();
...
this._progress$ = Observable.create(observer => {
…

Hammer
- 8,538
- 12
- 44
- 75
1
vote
1 answer
RxJava - single Observable executing right away - why?
I have a very simple RXJava emitter. It is a publishSubject actually but its job to convert Integers to strings and update a UI element afterwards when it subscribes. The code looks like this :
PublishSubject integerToStringEmitter =…

j2emanue
- 60,549
- 65
- 286
- 456
1
vote
1 answer
Creating a Subject
I'm implementing a byte message deserializer, which would dispatch deserialized messages on a dispatcher interface and return an observable of all Throwables thrown, so that client code can handle the errors.
A sketch of the prototype of the method…

Sebastian Graf
- 3,602
- 3
- 27
- 38
0
votes
3 answers
display async data in the angular view
i am fetching the data form an API beck-end and displaying its content in to my view in angular,
for the service i am using observables
export class PropertyService {
apiUrl: string = environment.domain;
constructor(private http: HttpClient)…

ibrahimgb
- 693
- 5
- 13
0
votes
2 answers
Call methods in sequence Angular 12
I have three methods say method1, method2 and method3 which are implemented in three different services. Please note that these three methods use httpClient in turn. (i.e. they return Observable). method2 is called from different places. In one of…

pmh
- 192
- 10
0
votes
1 answer
rx.js make combineLatest with inner WebSocket Subjects as Observable
Below My code works well.
But, I think combineLatest in other observable ($fromArray)'s operator (map) is weird.
How can I make combineLatest as observable itself?
const item = ["television", "pc", "radio", "camera"];
const fooMarket =…

reaver lover
- 624
- 7
- 20
0
votes
1 answer
In RxJS what is the difference between putting a mergeMap in a switchMap vs putting a mergeMap after a switchMap?
I don't understand the difference between these two chunks of code, I would expect identical behavior. The first one has a groupBy and mergeMap after the switchMap. The second one has them inside the switchMap.
const arraySubject = new…

user2690235
- 7
- 1
0
votes
1 answer
Angular – edit/remove element in a Subject Array
I have a Subject of Array of Users
private _currentHeroes = new Subject();
currentHeroes = this._currentHeroes.asObservable();
My goal is to edit only 1 element of the array without subscribing
Function of power up the user in my…

John
- 81
- 1
- 2
- 10
0
votes
0 answers
Undefined attribute after edit in subscribe
First of all, sorry for this presentation, It is not on the same computer.
I am trying to hide/show a panel using a boolean attribute in angular.
I got : public existsLegend: any = {}; and public isLegendPanelActive: boolean = false;
I coded a…

Fab83i
- 85
- 7
0
votes
0 answers
How to execute code inside method suscribe() before componant is init
I am trying to make that a component which is subscribed to a Subject executes the code related to the change of state of the Subject before the component is initialized (ngOnInit ()).
Here is the CartService:
.... import ....
@Injectable({
…

briandev
- 29
- 7
0
votes
1 answer
RxJS subscribe to change in subscribers count
Problem:
I'm using Subject observable to pass String data between components (that are too far apart in the hierarchy). I would like to be able to tell how many subscribers there are to the Subject when a component subscribes or unsubscribes. How…

MeIr
- 7,236
- 6
- 47
- 80