ComponentData(Prototype this, String id)
Summary
컴포넌트 데이터를 관리하는 프로토타입.
특정한 상황이 아니면 수정이 필요하지 않는 부분입니다.
사용예시
// ComponentMethod 메소드 안쪽에 실제 동작로직.
this.data = (new ComponentData(this, p.replace(/[^\w]/gi, ''))).preference;
// this.data에 ComponentData 객체를 할당하여 preference로 초기화.
Parameters
- Prototype this
ComponentData
는ComponentMethod
의 하위요소 입니다.따라서 ComponentData의 첫번째 인수는 ComponentMethod의 this를 전달합니다.
이 문맥에서 유추하실 수 있듯이 ComponentData는 오직 ComponentMethod안에서만 사용됩니다.
- String id
컴포넌트의 고유 ID를 전달합니다.
컴포넌트 고유 ID는
ComponentMethod
정의 당시 전달받으며,이를 이용하여 전역에 해시와 같이 관리됩니다.
Structure
Preference
ComponentData
의 데이터 변수입니다.이 변수를 이용해 모든 컴포넌트의 데이터를 관리합니다.
ComponentMethod
가 초기화 할 때 ComponentData를 호출 후 해당 변수를 this.data로 관리합니다.따라서, ComponentData는 특정한 상황이 아니면 수정하지 않습니다.
Preference의 구조
this.preference = {
$self: this, // 현재 컴포넌트 Prototype(ComponentData)
$super: context, // 상위 컴포넌트 Prototype(ComponentMethod)
$helper: null, // 헬퍼 메소드 Prototype(ComponentHelper)
_anim: false, // 컴포넌트의 Animation Status(Boolean)
_bind: false, // 컴포넌트 Binding Status(Boolean)
_debug: true, // 컴포넌트의 Debug Status(Boolean)
_init: false, // 컴포넌트 Initialization Status(Boolean)
anim: { // 컴포넌트 Animation Settings(Component)
time: 300,
effect: 'swing'
},
framework: 'homeworks', // 프레임워크 Full Name(String)
prefix: 'works', // 프레임워크 Brief(String)
id: '', // 컴포넌트 구분자(String)
element: { // 자주 참조하는 jQuery Component(Component)
$window: $(window),
$document: $(document)
},
global: {} // 컴포넌트 전역적 옵션
};
Preference의 명명규칙
_
로 시작하는 변수는 논리변수(boolean)를 의미합니다.
$
로 시작하는 변수는 참조변수(reference)를 의미합니다.