active-group / active-group/reacl-c-basics

debounce toggles state when reacl-c.core/init is involved

Đang mở
#15 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Clojure
Star
2
Fork
3
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

This code performs a 1 second debounce as I would expect:

```clojure
(ns todomvc.core
(:require [reacl-c.main :as main]
[reacl-c.dom :as dom :include-macros true]
[reacl-c.core :as c :include-macros true]
[reacl-c-basics.debounce :as debounce]))

(defn init []
(main/run
(.getElementById js/document "app")

(c/fragment
(c/dynamic pr-str)
(debounce/debounce-delay 1000 (c/with-state-as st
(dom/div

;; add this line to notice the flip-flop behaviour:
;; (c/init (c/return))

(dom/button {:onclick not}
(pr-str st))))))

{:initial-state false}
))

```

When you uncomment the `(c/init (c/return))` line, the behaviour changes: Now when you click the button, the state toggles between true and false every second.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.