mirror of https://github.com/logseq/logseq
refactor: move component state to state
parent
d05c540c15
commit
9d044f5834
|
@ -3,28 +3,26 @@
|
|||
[frontend.state :as state]
|
||||
[frontend.util :as util]))
|
||||
|
||||
(def state-store (atom {}))
|
||||
|
||||
(defn state-f [k]
|
||||
(fn [] (get @state-store k)))
|
||||
(fn [] (get @state/components k)))
|
||||
|
||||
(defn bind-state [k]
|
||||
{:after-render
|
||||
(fn [state]
|
||||
(js/setTimeout
|
||||
(fn []
|
||||
(swap! state-store assoc k state))
|
||||
(swap! state/components assoc k state))
|
||||
100)
|
||||
state)
|
||||
|
||||
:did-remount
|
||||
(fn [_ new-state]
|
||||
(swap! state-store assoc k new-state)
|
||||
(swap! state/components assoc k new-state)
|
||||
new-state)
|
||||
|
||||
:will-unmount
|
||||
(fn [state]
|
||||
(swap! state-store dissoc k)
|
||||
(swap! state/components dissoc k)
|
||||
state)})
|
||||
|
||||
(defn before [f shortcut-map]
|
||||
|
|
|
@ -1168,3 +1168,8 @@
|
|||
(defn set-copied-blocks
|
||||
[content ids]
|
||||
(set-state! :copy/blocks {:copy/content content :copy/block-tree ids}))
|
||||
|
||||
(defonce components (atom {}))
|
||||
|
||||
(defn auto-complete? []
|
||||
(some? (get @components :component/auto-complete)))
|
||||
|
|
Loading…
Reference in New Issue