Slide 15
Slide 15 text
Presentation層サンプルコード
const task = await controller.findByID(query.id)
const { formattedTitle } = useTask(task)
{ formattedTitle }
{
task.isDone()
? controller.delete(task)}>Delete
: controller.update(task, input)}>Update
}
// ViewModel
function useTask(task: Task) {
const formattedTitle = useMemo(() => {
const status = task.isExpired() ? 'Warning' : 'Progress'
const title = task.title()
return `${status}: ${title}`
}, [...])
return { formattedTitle }
}