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))))))))