0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 08:50:57 -05:00

Changed order of plugins initialization

This commit is contained in:
alonso.torres 2024-06-21 12:44:35 +02:00
parent c70d20f95d
commit fb1429956a
3 changed files with 20 additions and 15 deletions

View file

@ -105,8 +105,7 @@
(rx/map deref)
(rx/filter du/is-authenticated?)
(rx/take 1)
(rx/map #(ws/initialize))
(rx/tap #(plugins/init!)))))))
(rx/map #(ws/initialize)))))))
(defn ^:export init
[]
@ -116,7 +115,8 @@
(cur/init-styles)
(thr/init!)
(init-ui)
(st/emit! (initialize)))
(st/emit! (plugins/initialize)
(initialize)))
(defn ^:export reinit
([]

View file

@ -16,15 +16,20 @@
[beicon.v2.core :as rx]
[potok.v2.core :as ptk]))
(defn init!
(defn init-plugins-runtime!
[]
(->> st/stream
(rx/filter (ptk/type? ::features/initialize))
(rx/take 1)
;; We need to wait to the init event to finish
(rx/observe-on :async)
(rx/subs!
(fn []
(when (features/active-feature? @st/state "plugins/runtime")
(when-let [init-runtime (obj/get global "initPluginsRuntime")]
(init-runtime (fn [plugin-id] (api/create-context plugin-id)))))))))
(init-runtime (fn [plugin-id] (api/create-context plugin-id)))))
(defn initialize
[]
(ptk/reify ::initialize
ptk/WatchEvent
(watch [_ _ stream]
(->> stream
(rx/filter (ptk/type? ::features/initialize))
(rx/observe-on :async)
(rx/filter #(features/active-feature? @st/state "plugins/runtime"))
(rx/take 1)
(rx/tap init-plugins-runtime!)
(rx/ignore)))))

View file

@ -27,6 +27,6 @@
(defn ^:export plugins []
(st/emit! (features/enable-feature "plugins/runtime"))
(plugins/init!)
(plugins/init-plugins-runtime!)
nil)