@log
    export class C {
      @bound
      @startAndEnd()
      eat() {
        console.log('Eat');
      }
    
      @bound @startAndEnd() work() {
        console.log('Work');
      }
    
      @startAndEnd('시작', '끝')
      sleap() {
        console.log('Sleap');
      }
    }
    

    context에는 addInitializer라는 메서드도 있습니다. bound 데코레이터를 보면 contextaddInitializer 메서드를 호출하고 있습니다. addInitializer에 등록한 함수는 클래스의 인스턴스를 생성할 때(초기화)에 호출됩니다. 즉, new C()를 할 때 this.eat = this.eat.bind(this)가 호출됩니다.

    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.