Skip to content

refactor(afternote): 에디터 폼 갱신 통로 updateForm 을 개별 콜백으로 분리 — 파사드 19개 지점 #674

Closed as not planned

Description

@OnlyReadOneBook

📜 Overview (Required)

에디터 폼 갱신이 updateForm 이라는 상태 변환 람다 하나를 통로로 쓴다. UI 파사드가 (EditorFormState) -> EditorFormState 를 받아 ViewModel 이 소유한 폼 SSOT 를 임의로 변환하는 구조다.

// AfternoteEditorViewModel.kt:204
fun updateForm(block: (EditorFormState) -> EditorFormState) {
    internalState.update { prev -> prev.copy(form = block(prev.form)) }
    persistFormSnapshot(internalState.value.form)
}

파사드 AfternoteEditorState 가 이 통로를 19곳에서 쓴다 — syncMemorialPlaylistSongs(71) · resetMemorialPlaylistFormSnapshot(76) · selectCategory(90, private — onCategorySelected·selectCategoryByNavKey 가 호출) · onServiceSelected(104) · onMemorialPhotoSelected(109) · onFuneralVideoSelected(113) · onFuneralThumbnailDataUrlReady(117) · onAddCustomService(130) · onAddAfternoteEditorReceiver(140) · onAfternoteEditorReceiverDelete(155) · addReceiverFromSelection(168) · replaceReceiversIfEmpty(182) · addEditorMessage(190) · removeEditorMessage(200) · persistEditorMessagesFromTyping(233) · applyFormPrefill(248) · addProcessingMethod(268) · deleteProcessingMethod(279) · editProcessingMethod(288).

공식 가이드가 권장하는 형태는 개별 콜백이다. State holders 는 "If the shorter-lived state holder needs certain information from a higher-scoped state holder, pass only the information it needs as a parameter instead of passing the state holder instance." 라고 적고, 예제에서 private val doSomething: () -> Unit 처럼 필요한 동작만 개별로 받는 형태를 보여 준다. UI layer 의 "Only sources or owners of data should be responsible for updating the data they expose." 도 같은 방향이다.

⚠️ 다만 "상태 변환 람다" 를 금지하는 문장은 두 문서 어디에도 없다(원문 대조 완료). 현 구조는 ViewModel 인스턴스를 넘기지 않으므로 명시적 금지 대상은 아니고, "권장 예시에서 벗어나 있다" 가 정확한 표현이다. 이 선을 넘겨 근거로 삼지 말 것.

작업: 파사드 19개 지점이 updateForm { ... } 대신 각자 대응하는 ViewModel 콜백을 호출하도록 바꾸고, 실제 copy(...) 는 ViewModel 안에서 수행한다. 파사드의 공개 메서드 이름·시그니처는 유지되므로 컴포저블 호출부는 영향이 없다.

📍 Note (Optional)

Activity

  1. changed the title [-]refactor(afternote): 에디터 폼 갱신 통로 updateForm 을 개별 콜백으로 분리 — 파사드 20개 함수[/-] [+]refactor(afternote): 에디터 폼 갱신 통로 updateForm 을 개별 콜백으로 분리 — 파사드 19개 지점[/+] on Aug 2, 2026
  2. OnlyReadOneBook commented on Aug 2, 2026

    @OnlyReadOneBook
    CollaboratorAuthor

    #675 로 합본한다.

    두 작업이 AfternoteEditorState 의 같은 19개 updateForm { it.copy(...) } 블록을 각자 재작성해서, 나눠 진행하면 뒤엣것이 앞엣것을 통째로 다시 쓴다. 이 이슈의 내용(공식 문서 근거·2026-05-02 "reducer 유지" 결정 역전 기록·대상 19개 지점 목록)은 #675 본문으로 옮겼다.

    작업 자체가 취소된 것이 아니라 #675 에서 함께 처리된다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions