Issue
I would like to know wether there is a simple way to find out, wether I am dealing with the initial-value of a BehaviourSubject or wether it has been changed by "next".
Solution
The BehaviourSubject
has not such a field. But it is pretty simple to define it yourself.
const yourSubject$<string> = new BehaviourSubject('test');
let subjectChanged = false;
yourSubject
.pipe(
distinct(), // if you want to ignore same values
skip(1), // ignore the initial value
take(1), // only take one change
)
.subscribe(() => subjectChanged = true);
A emit with a other value will cause, that subjectChanged
will switch to true
.
Answered By - akop
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.