I have observable that emitting values every N seconds and I have. I want to take the first emission and fire a function on that.
I have this code:
sideEffect = false;
observable$
.pipe(
tap((data) => {
// executing this only for the first emission
if (!sideEffect) {
this.sideEffect(data.props);
sideEffect = true;
}
})
)
.subscribe((data) => {
// process all upcoming emissions
});
Is there anyway to make this code better using RxJS operators without defining any local variables?