문제

I found in requirejs-text plugin weird code. So load method accepts onLoad callable which is invoked for a few times as onLoad(), but later there is error handler which checks for an error method.

if (onLoad.error) {
    onLoad.error(err);
}

Am i missing something or it's obvious code issue?

도움이 되었습니까?

해결책

You cannot use a normal object as a callable entity, but a function is a type of object, so you can add properties to a function.

var onLoad = function(){

};

onLoad.error = function(){

};
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top