I have a subject search2Sub$ that is being emitted twice. I trigger it only one time in component1 after user stopped typing. Could youp please help figuring out what am I doing wrong?
appService
search2Sub$ = new Subject<boolean>()
component1
ngOnInit(): void {
this.appService.search1Sub$.pipe (
debounceTime(2000),
).subscribe(value => {
this.appService.search2Sub$.next(true)
});
}
component2
this.appService.search2Sub$.subscribe(data=>{
console.log(value)
})
ngOnDestroy(): void {
this.appService.search2Sub$.unsubscribe()
}
The resolution was saving as subscription and then unsubscribe from it
rxjs take operator didn't do a trick.