IT
RXJS Observable 구독 중에 구독 취소하기 / 옵저버블 강제 구독 해제
agnusdei1207
2023. 7. 15. 19:26
반응형
SMALL
const sub = this.scrollService.getScrollY().subscribe({ // 구독 시작
next: (scrollY) => { // 스크롤 좌표에 해당하는 페이지 넘버 1~8 리턴
const pageIndex = sections.findIndex((section) =>
this.checkVisible(section.nativeElement)
);
// 마지막 페이지일 경우 구독 중지
if (pageIndex === 8) {
sub.unsubscribe();
}
},
});
반응형
LIST