1
Underscore _.compose
메서드를 사용하면 컴포지션에서 개체 메서드를 호출하고 호출되는 메서드를 소유하는 개체에 컨텍스트를 설정할 수 있습니까? ObjectOne.methodName()
가 실행되면Underscore.compose에서 개체 메서드 호출
example: function(data) {
return _.compose(
ObjectOne.methodName,
ObjectTwo.methodName
)(data);
}
, 나는 ObjectOne
로 this
를 원한다. 그러나 두 메서드 호출 모두에서 컨텍스트로 Window
을 얻게됩니다. 이
example: function(data) {
return _.compose(
ObjectOne.methodName.bind(ObjectOne),
ObjectTwo.methodName.bind(ObjectTwo)
)(data);
}
bind
전화와 같은
신속하게 응답 해 주셔서 감사드립니다. 잠시 후 받아 들일 것입니다. – cantera