Installation
Install the package with your preferred package manager
선호하는 패키지 매니저로 패키지를 설치하세요
Demo example
DEMO EXAMPLE
데모 예제
Architecture Overview
Understanding dom-render's reactive architecture
dom-render의 반응형 아키텍처 이해하기
Core Architecture
dom-render uses a Proxy-based reactivity system for automatic DOM updates
dom-render는 자동 DOM 업데이트를 위해 Proxy 기반 반응형 시스템을 사용합니다
graph TB A[User State Object] -->|Wrap with Proxy| B[DomRenderProxy] B -->|Track Changes| C[Property Access/Set] C -->|Detect Changes| D[Messenger] D -->|Notify| E[Operators] E -->|Update| F[DOM Elements] G[Template String] -->|Parse| H[Dr Operators] H -->|Create| I[Virtual Elements] I -->|Render| F J[Components] -->|Extend| K[ComponentBase] K -->|Use| B K -->|Lifecycle| L[OnInit/OnDestroy] M[Router] -->|Path/Hash| N[Route Match] N -->|Load| J style A fill:#e1f5ff style B fill:#fff4e6 style D fill:#f3e8ff style F fill:#dcfce7 linkStyle default stroke:#aaaaaa,stroke-width:2px
Reactivity Flow
How state changes propagate to the DOM
상태 변경이 DOM으로 전파되는 방식
sequenceDiagram participant User participant State participant Proxy participant Messenger participant Operator participant DOM User->>State: state.count++ State->>Proxy: set trap triggered Proxy->>Proxy: Compare old vs new value alt Value Changed Proxy->>Messenger: notify(property, newValue) Messenger->>Operator: processUpdate() Operator->>Operator: Parse template expression Operator->>DOM: Update textContent/attribute DOM-->>User: Visual update else No Change Proxy-->>User: Skip update end
Component Lifecycle
ComponentBase lifecycle hooks execution order
ComponentBase 생명주기 훅 실행 순서
sequenceDiagram participant App participant Component participant DomRender participant DOM App->>Component: new MyComponent() Component->>Component: constructor() Component->>DomRender: Initialize proxy DomRender->>Component: OnInitRender() Component->>Component: Setup initial state DomRender->>DOM: Render template DomRender->>Component: OnCreateRendered() Component->>Component: Query DOM elements Component->>Component: Attach event listeners Note over Component,DOM: Component is active App->>Component: destroy() Component->>Component: OnDestroyRender() Component->>Component: Cleanup resources DomRender->>DOM: Remove elements
Operator System
Built-in operators for template directives
템플릿 지시어를 위한 내장 연산자
graph LR A[Template] --> B{Operator Type} B -->|dr-if| C[DrIf] B -->|dr-for-of| D[DrFor] B -->|dr-choose| E[DrChoose] B -->|dr-attr| F[DrAttr] B -->|dr-class| G[DrClass] B -->|dr-style| H[DrStyle] B -->|dr-form| I[DrForm] B -->|dr-event| J[DrEvent] B -->|Expression| K[Dr] C --> L[Conditional Render] D --> M[List Render] E --> N[Switch Case] F --> O[Dynamic Attrs] G --> P[Dynamic Classes] H --> Q[Dynamic Styles] I --> R[Form Binding] J --> S[Event Handling] K --> T[Data Binding] style B fill:#fef3c7 style L fill:#dcfce7 style M fill:#dcfce7 style N fill:#dcfce7 style O fill:#e0e7ff style P fill:#e0e7ff style Q fill:#e0e7ff style R fill:#fce7f3 style S fill:#fce7f3 style T fill:#dbeafe linkStyle default stroke:#aaaaaa,stroke-width:2px
Getting Started
Quick start with basic examples
기본 예제로 빠르게 시작하기
Basic Reactive Binding
Create a reactive state object that automatically updates the DOM
DOM을 자동으로 업데이트하는 반응형 상태 객체 생성
Two-Way Data Binding
Bind input elements to state with automatic synchronization
자동 동기화로 입력 요소를 상태에 바인딩
Array Binding
Reactive array manipulation with automatic list rendering
자동 리스트 렌더링을 통한 반응형 배열 조작
Core Features
Essential reactive templating and component features
필수 반응형 템플릿과 컴포넌트 기능
DomRender Class
Main rendering engine with reactive data binding
반응형 데이터 바인딩을 가진 메인 렌더링 엔진
PROPERTIES & METHODS속성 및 메서드
rootObject
: TGet the proxied reactive state object프록시된 반응형 상태 객체 가져오기config
: DomRenderConfigGet configuration object설정 객체 가져오기router
: RouterGet router instance (PathRouter or HashRouter)라우터 인스턴스 가져오기 (PathRouter 또는 HashRouter)eventManager
: EventManagerGet event manager for DOM event handlingDOM 이벤트 처리를 위한 이벤트 매니저 가져오기target
: Element | nullGet target DOM element대상 DOM 요소 가져오기static run
(data: DomRenderRunParameter ): TStatic method to create and run DomRender, returns proxied stateDomRender 생성 및 실행 정적 메서드, 프록시된 상태 반환
ComponentBase
Base class for building encapsulated, reusable components with lifecycle hooks and decorators
생명주기 훅과 데코레이터를 가진 캡슐화된 재사용 가능 컴포넌트를 만들기 위한 기본 클래스
LIFECYCLE HOOKS생명주기 훅
OnInitRender
(): voidCalled once when component is initialized, before first render컴포넌트 초기화 시 첫 렌더링 전에 한 번 호출OnCreateRenderData
(params: OnCreateRenderDataParams): voidCalled before render, can modify render data렌더링 전 호출, 렌더 데이터 수정 가능OnCreateRendered
(): voidCalled after first render complete, DOM elements available첫 렌더링 완료 후 호출, DOM 요소 사용 가능OnRawSetRendered
(render: Render, otherData: OnRawSetRenderedOtherData): voidCalled after each re-render매 재렌더링 후 호출OnChangeAttrRender
(attrName: string, newValue: any, otherData: OtherData): voidCalled when attribute changes속성 변경 시 호출OnDestroyRender
(params: OnDestroyRenderParams): voidCalled when component is destroyed, cleanup resources컴포넌트 파괴 시 호출, 리소스 정리
DECORATORS데코레이터
@attribute
(name?: string | {name?, converter?})Bind HTML attribute to component property, supports custom converterHTML 속성을 컴포넌트 속성에 바인딩, 커스텀 변환기 지원@query
(selector | {selector, convert?, onDestroy?, refreshIntervalTime?})Query and bind DOM element to property, auto-refresh supportDOM 요소 쿼리 및 속성에 바인딩, 자동 새로고침 지원@event
(eventName, selector, {onDestroy?, refreshIntervalTime?}?)Declarative event listener binding with auto-cleanup자동 정리 기능이 있는 선언적 이벤트 리스너 바인딩
ComponentSet
Create lightweight component instances without custom elements
커스텀 요소 없이 경량 컴포넌트 인스턴스 생성
Control Flow Directives
Template directives for dynamic rendering and control flow
동적 렌더링과 제어 흐름을 위한 템플릿 지시어
dr-if - Conditional Rendering
Show/hide elements based on boolean expressions
불린 표현식에 따라 요소 표시/숨김
dr-for-of - List Rendering
Iterate over arrays with reactive updates
반응형 업데이트로 배열 반복
dr-choose - Switch Cases
Switch-like conditional rendering with multiple branches
여러 분기가 있는 스위치형 조건부 렌더링
Dynamic Binding
Dynamic attribute, class, style, and event binding
동적 속성, 클래스, 스타일, 이벤트 바인딩
dr-attr - Attribute Binding
Dynamically bind multiple HTML attributes
여러 HTML 속성을 동적으로 바인딩
dr-class - Class Binding
Conditionally apply CSS classes
조건부로 CSS 클래스 적용
dr-style - Style Binding
Dynamically bind inline styles
인라인 스타일을 동적으로 바인딩
dr-event - Event Binding
Declarative event handling with inline expressions
인라인 표현식으로 선언적 이벤트 처리
Forms & Validation
Powerful form handling with built-in validation
내장 검증 기능이 있는 강력한 폼 처리
dr-value - Two-Way Binding
Automatic synchronization between state and form inputs
상태와 폼 입력 간 자동 동기화
dr-form - Form Binding
Complete form state management with validation
검증 기능이 있는 완전한 폼 상태 관리
Validators
Built-in form validators
내장 폼 검증기
OTHER VALIDATORS기타 검증기
RequiredValidator
Required field validation필수 필드 검증ValueEqualsValidator
Value equality validation값 동일성 검증AllCheckedValidatorArray
All items checked validation모든 항목 체크 검증CountEqualsCheckedValidatorArray
Specific count checked validation특정 개수 체크 검증
Client-Side Routing
Built-in router for single-page applications (SPA)
싱글 페이지 애플리케이션을 위한 내장 라우터
Router Setup
Configure router type (hash or path based)
라우터 타입 설정 (해시 또는 경로 기반)
dr-route-match - Route Definition
Define routes with path patterns and parameters
경로 패턴과 파라미터로 라우트 정의
Async Operations
Declarative handling of asynchronous operations
비동기 작업의 선언적 처리
dr-promise-switch - Promise States
Render different UI based on Promise state (pending/fulfilled/rejected)
Promise 상태(대기/완료/거부)에 따라 다른 UI 렌더링
dr-timer - Interval Updates
Execute code at regular intervals
정기적인 간격으로 코드 실행