enhance: sub-editing? add use-memo, use-callback

This commit is contained in:
rcmerci
2025-04-07 01:11:46 +08:00
parent c93376b98b
commit 17ef19325a

View File

@@ -694,13 +694,18 @@ Similar to re-frame subscriptions"
(defn sub-editing?
[container-block]
(let [checkf (fn [s] (boolean (get s container-block)))
init-value (checkf @(:editor/editing? @state))]
(hooks/use-flow-state
init-value
(m/eduction
(map checkf) (drop-while #(= % init-value)) (dedupe)
editing-flow))))
(let [checkf (hooks/use-callback
(fn [s] (boolean (get s container-block)))
[container-block])
init-value (checkf @(:editor/editing? @state))
flow (hooks/use-memo
#(m/eduction
(map checkf)
(dedupe)
(drop-while (fn [x] (identical? x init-value)))
editing-flow)
[init-value])]
(hooks/use-flow-state init-value flow)))
(defn sub-config
"Sub equivalent to get-config which should handle all sub user-config access"