I want to re-emit the last value of a BehaviourSubject
to the existing subscriptions. I tried last()
, publishlast()
, share()
, refcount()
. But it doesn't trigger the existing subscriptions again with the last emitted value.
I want to re-emit the last value of a BehaviourSubject
to the existing subscriptions. I tried last()
, publishlast()
, share()
, refcount()
. But it doesn't trigger the existing subscriptions again with the last emitted value.
-
this.subject.take(1).subscribe(item => this.subject.next(item))
? But why do you need to do this; what's the context? – jonrsharpe Commented Mar 4, 2018 at 22:27 - This looks like it is setting up the subscriber. I want the subject to re-emit the last value. – coderman Commented Mar 4, 2018 at 22:46
- It does, and that is what it does. It will take one value, a replay of the last value, and push it back into the subject to get re-emitted. – jonrsharpe Commented Mar 5, 2018 at 8:11
1 Answer
Reset to default 5If sub is your BehaviorSubject, this would work:
sub.next(sub.value)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745392669a4625734.html
评论列表(0条)