0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-13 16:21:57 -05:00

🐛 Fix problem when initializing plugin

This commit is contained in:
alonso.torres 2024-05-24 11:52:53 +02:00 committed by Andrey Antukh
parent 4b05ee35b8
commit 519b2d7f04

View file

@ -11,11 +11,20 @@
[app.main.store :as st]
[app.plugins.api :as api]
[app.util.globals :refer [global]]
[app.util.object :as obj]))
[app.util.object :as obj]
[beicon.v2.core :as rx]
[potok.v2.core :as ptk]))
(defn init!
[]
(when (features/active-feature? @st/state "plugins/runtime")
(when-let [init-runtime (obj/get global "initPluginsRuntime")]
(let [context (api/create-context)]
(init-runtime context)))))
(->> 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")]
(let [context (api/create-context)]
(init-runtime context))))))))