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

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

未關閉
#15 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Clojure
星號
2
分支
3
PR 合併指標
30 天內沒有已合併 PR

描述

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.

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

Start with the supplied todomvc.core example, especially debounce/debounce-delay and the reacl-c.core/init and return calls. Reproduce the behavior with and without (c/init (c/return)), then trace how the debounce and state update interact. Done means the optional init call no longer makes button state alternate every second; the issue does not name a test file to run.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
clojure
領域
frontend, web-dev
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。