2025-12-01

UseCase로 가야 하는 것

비즈니스 검증 로직 ✨

if (todo.title.isEmpty) throw ValidationError();

데이터 변환 ✨

final normalizedTodo = todo.copyWith(
  title: todo.title.trim(),
  description: sanitize(todo.description),
);

복잡한 계산이나 대용량 데이터 처리

final priority = calculatePriority(todo, userPreferences);
final processedData = await processBulkData(eDataset);



ViewModel에 남아야 하는 것

UI 업데이트 조작에 관련된 로직 ✨

final idx = list.indexWhere((e) => e.id == todo.id);
state = AsyncData([...list]..[idx] = todo); // 낙관적 업데이트

State 관리

state = AsyncLoading();
state = AsyncData(data);
state = AsyncError(error, stack);



태그:

카테고리:

업데이트: