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

@ -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)))))))))
(when-let [init-runtime (obj/get global "initPluginsRuntime")]
(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)))))