From 519b2d7f04667f751057dc31d1bb350100da545f Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 24 May 2024 11:52:53 +0200 Subject: [PATCH] :bug: Fix problem when initializing plugin --- frontend/src/app/plugins.cljs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/plugins.cljs b/frontend/src/app/plugins.cljs index fcfa218570..8bd6d5ebbe 100644 --- a/frontend/src/app/plugins.cljs +++ b/frontend/src/app/plugins.cljs @@ -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))))))))