Uni-class / catch-up-repo

CatchUP: 강의 환경 동기화를 위한 솔루션
https://catchup.tools
2 stars 0 forks source link

FE: PaintPDF 이벤트 핸들러 아키텍쳐 #511

Closed nayounsang closed 1 day ago

nayounsang commented 2 days ago

📝 개요

✔️ To-Do

예상 마감 기한

👀 ETC

    listen(onHistory: StoreListener<R>, filters?: Partial<StoreListenerFilters>) {
        // flush history so that this listener's history starts from exactly now
        this._flushHistory()

        const listener = {
            onHistory,
            filters: {
                source: filters?.source ?? 'all',
                scope: filters?.scope ?? 'all',
            },
        }

        this.listeners.add(listener)

        if (!this.historyReactor.scheduler.isActivelyListening) {
            this.historyReactor.start()
        }

        return () => {
            this.listeners.delete(listener)

            if (this.listeners.size === 0) {
                this.historyReactor.stop()
            }
        }
    }