Improve event registry.

This commit is contained in:
Andrey Antukh 2021-09-06 15:00:18 +02:00 committed by Andrés Moya
parent b5b97f7626
commit 926fa483b9
25 changed files with 245 additions and 93 deletions

View file

@ -12,12 +12,14 @@
[beicon.core :as rx]
[rumext.alpha :as mf]))
(mf/defc copy-button [{:keys [data]}]
(mf/defc copy-button [{:keys [data on-copied]}]
(let [just-copied (mf/use-state false)]
(mf/use-effect
(mf/deps @just-copied)
(fn []
(when @just-copied
(when (fn? on-copied)
(on-copied))
(let [sub (timers/schedule 1000 #(reset! just-copied false))]
;; On unmount we dispose the timer
#(rx/-dispose sub)))))