I have an Angular application where I use RxJS BehaviorSubject to subscribe to a bool value that indicates an "in progress" status.
But I'm only interested in when the state changes and not the current state on subscription.
export class ProgressService {
private InProgress$ = new BehaviorSubject<boolean>(false);
constructor() {}
public getInProgressStateSubject() {
return this.InProgress$;
}
}
...
this.progressService.getInProgressSubject().subscribe((inProgress: boolean) => {
// This will be triggered in the moment of subscription as well as on state chages
if (inProgress) {
// Toggle on state
} else {
// Toggle off state
}
});
I like how it works, I just don't want it to trigger on subscription.
Are there any other similar operators in RxJS that can help me, or can I do it in any other way?
Thanks!