Fork me on GitHub
#vrac
<
2021-09-23
>
phronmophobic20:09:44

I was just taking another look at vrac. It seems like there's a lot of similarities with https://blog.phronemophobic.com/reusable-ui-components.html. Is there an example for how effects might work?

(defc todo-item-comp [todo-item]
  {:id :my-app/todo-item}
  [:.title {:class {:done? (:todo-item/done? todo-item)}}
           (:todo-item/title todo-item)])
How would you emit a :toggle-todo for todo-item when the user clicks on the todo item?

Vincent Cantin03:09:09

@U7RJTCH6J It would look like:

(defc todo-item-comp [todo-item]
  {:id :my-app/todo-item}
  [:div.title {:class [(when (:todo-item/done? todo-item)
                          :done?)]
               :on-click [:toggle-todo todo-item]}
   [:todo-item/title todo-item]]])