2017-03-18 18 views
1

나는 react와 mobx가있는 응용 프로그램을 가지고 있으며 일부 검색을 수행하기 위해 모든 로깅 사용자 상호 작용 (작업 호출)을 Mobx 상점에서 분리하고 싶습니다. 프록시 패턴이이 최선의 방법이라는 것을 알았습니다 직원 및 내 질문에 어떻게 내 Mobx 및 프록시 작업 할 수 있습니다. 감사의 말mobx와 프록시 사용 Store

답변

0

이 목적으로 spy을 사용할 수 있습니다. 당신이 시간

예 (JS Bin)

class Store { 
    @observable count = 1; 
    @action 
    increment(step) { 
    this.count = this.count + step; 
    } 
} 

const store = new Store(); 

setInterval(() => store.increment(store.count), 1000); 

spy((event) => { 
    if (event.type === 'action') { 
    console.log(`${event.name} with args: ${event.arguments}`); 
    } 
}); 
+1

감사의 –