import {
Observable,
BehaviorSubject
} from 'rxjs';
import {
finalize,
share
} from 'rxjs/operators'
export class someComponent() {
public count$ = new BehaviorSubject < any > (0);
public constructor() {
this.shareResponse()
.pipe(
finalize(() => {
console.log('finalize called');
}))
.subscribe((event: any) => {
// Do something
});
}
public shareResponse(): Observable < any > {
return this.count$.pipe(share());
}
public countChanged(event) {
this.count$.next(event);
}
}
HTML:
<some-tag(countChanged) = (countChanged($event)) > < /some-tag>