2018년 9월 7일

오늘 한 일:

내일 할 일:

React

music-player

dummy 뮤직 코어 생성

기능

설계

class DummyCore {
    constuctor(music) {
        this.music = music
        this.currentTime = 0;
        this.intervalID = null;
        this.onReturnCurrentTime = null;
        // {runningTime: 200000}
    }
    play() {
        this.intervalID = setInterval(() => {
            this.currentTime += 1000;
            if(this.currentTime > this.runnigTime){
                this.currentTIme = this.runningTime
                this.pause();
            }
            else this.onReturnCurrentTime(this.currentTime);
        }, 1000);
    }
    pause() {
        clearInterval(this.id);
    }
    set(time) {
        this.currentTime = time;
    }
}

dummy 뮤직 코어와 연결

promise 사용해서 setState 비동기 메소드의 순서를 정함

componentDidUpdate(prevProps[, prevState[, snapshot]]): 부모 컴포넌트에서 자식 컴포넌트를 리렌더링 할 시 자식 컴포넌트에서 사용해야 업데이트 된다

Play and Pause 기능 추가