Questions tagged [replaysubject]

9 questions
5
votes
3 answers

Make a ReplaySubject return only the last value on subscribe

I have a strange use case where I need to keep track of all previous emitted events. Thanks to the ReplaySubject, it works perfectly so far. On every new subscriber, this Subject re-emits every previous events. Now, for a specific scenario, I need…
Anas Bud
  • 347
  • 4
  • 15
4
votes
3 answers

rxjs withLatestFrom unExpected behavior

import { of, Subject, interval } from 'rxjs'; import { tap, startWith, map, delay, publishReplay, publish, refCount, withLatestFrom, switchMap, take } from 'rxjs/operators'; const a$ = new Subject(); const b$ = a$.pipe( map(a…
孙雪姣
  • 41
  • 2
3
votes
2 answers

Deep diving into Rx.ReplaySubject: How to delay `next()`?

Ignoring Block: Either I'm wrong here, or the whiskey is starting to work. (I don't want to rule out that I'm going stupid either. Sorry for that.) Expectation: I would have expected ReplaySubject to return a single value every 2 seconds because I…
user3025289
1
vote
2 answers

ReplaySubject read all values

I am trying to read all emitted values of a replaySubject. selectedPersons = new ReplaySubject(); sub = new Subscription; -- ngOnInit() { this.subscription = this.selectedPersons.subscribe((resp) => { console.log(this.selectedPersons) …
Atropos
  • 13
  • 1
  • 5
0
votes
0 answers

Why subject isn't working inside SwitchMap?

I set up a service to make an http Request. private readonly changeSelectedId$ = new Subject(); private readonly selectedId$ = this.changeSelectedId$.pipe( distinctUntilChanged(), untilDestroyed(this), switchMap((id)…
Giuseppe Pennisi
  • 396
  • 3
  • 22
0
votes
0 answers

Method next() on ReplaySubject not working in subscribe

I have a that code: enum URLs { 'STORY_BUILDER' = 'story-builder', 'IB_VIEW' = 'ib-view', } defaultGroupStoryRequest$ = new ReplaySubject(); defaultGroupIbViewRequest$ = new ReplaySubject(); const invalidRequest =…
0
votes
1 answer

Select ReplaySubject values emitted untill now

Is there reliable solution to get a snapshot of values currently buffered in ReplaySubject? I came up with something like this, but not sure how reliable this solution is: replaySubject.pipe( takeUntil(timer(10).pipe(take(1))) ) The timer…
gxx
  • 73
  • 1
  • 4
0
votes
1 answer

How to unsubscribe behaviour subject in angular8

Hi i am using Angular8 application, in which i have used Replay subject and Behaviour subject, for the initial click it hits the api for only 1 time, but if i change between tabs, the subscription hits fr multiple times, if i have clicked tab for 3…
Bhrungarajni
  • 2,415
  • 11
  • 44
  • 88
-1
votes
1 answer

Event is fired without any call to .next()

the problem i have is, every time the component VisOpComponent is initialized, the subscribed eventemitter gets fired without any call to .next(). i also added some console.log as shown below to show you that, despite…
Amrmsmb
  • 1
  • 27
  • 104
  • 226