-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throwing exception when accessing unstarted state in cljs #95
Comments
the idea behind starting the state at
can you provide an example? |
Hi, sorry for the late reply! Steps to reproduce:
You will see in the console log that several states is started more than once and possibly in the wrong order. In my case it's |
started several times, states started in exactly the same order: {:started
["#'lotus.command/event-dispatcher"
"#'lotus.command/effect-dispatcher"
"#'lotus.config/config"
"#'lotus.datastore/datastore-conn"
"#'lotus.ws/ws-remote"
"#'lotus.command.listener/event-listener"
"#'lotus.command.listener/effect-listener"
"#'lotus.datastore.bootstrapper/datastore-conn-bootstrapper"
"#'lotus.datastore.watcher/datastore-conn-watcher"
"#'lotus.datastore.listener/datastore-conn-listener"
"#'lotus.ws.listener/ws-listener"
"#'lotus.router/ring-middleware"
"#'lotus.router/ring-router"
"#'lotus.web/web-server"
"#'lotus.figwheel/figwheel-server"]} you could also use => (require '[mount.tools.graph :as graph]) => (graph/states-with-deps)
({:name "#'lotus.command/event-dispatcher",
:order 1,
:status #{:started},
:deps #{}}
{:name "#'lotus.command/effect-dispatcher",
:order 2,
:status #{:started},
:deps #{}}
{:name "#'lotus.config/config",
:order 3,
:status #{:started},
:deps #{}}
{:name "#'lotus.datastore/datastore-conn",
:order 4,
:status #{:started},
:deps #{"#'lotus.config/config"}}
{:name "#'lotus.ws/ws-remote",
:order 5,
:status #{:started},
:deps #{}}
{:name "#'lotus.command.listener/event-listener",
:order 6,
:status #{:started},
:deps
#{"#'lotus.ws/ws-remote" "#'lotus.datastore/datastore-conn"
"#'lotus.command/effect-dispatcher" "#'lotus.config/config"
"#'lotus.command/event-dispatcher"}}
{:name "#'lotus.command.listener/effect-listener",
:order 7,
:status #{:started},
:deps
#{"#'lotus.ws/ws-remote" "#'lotus.datastore/datastore-conn"
"#'lotus.command/effect-dispatcher" "#'lotus.config/config"
"#'lotus.command/event-dispatcher"}}
{:name "#'lotus.datastore.bootstrapper/datastore-conn-bootstrapper",
:order 8,
:status #{:started},
:deps #{"#'lotus.datastore/datastore-conn"}}
{:name "#'lotus.datastore.watcher/datastore-conn-watcher",
:order 9,
:status #{:started},
:deps
#{"#'lotus.datastore/datastore-conn"
"#'lotus.datastore.bootstrapper/datastore-conn-bootstrapper"}}
{:name "#'lotus.datastore.listener/datastore-conn-listener",
:order 10,
:status #{:started},
:deps
#{"#'lotus.command/event-dispatcher"
"#'lotus.datastore.watcher/datastore-conn-watcher"}}
{:name "#'lotus.ws.listener/ws-listener",
:order 11,
:status #{:started},
:deps #{"#'lotus.ws/ws-remote" "#'lotus.command/event-dispatcher"}}
{:name "#'lotus.router/ring-middleware",
:order 12,
:status #{:started},
:deps
#{"#'lotus.ws/ws-remote" "#'lotus.datastore/datastore-conn"
"#'lotus.config/config"}}
{:name "#'lotus.router/ring-router",
:order 13,
:status #{:started},
:deps
#{"#'lotus.ws/ws-remote" "#'lotus.datastore/datastore-conn"
"#'lotus.config/config"}}
{:name "#'lotus.web/web-server",
:order 14,
:status #{:started},
:deps #{"#'lotus.router/ring-router" "#'lotus.config/config"}}
{:name "#'lotus.figwheel/figwheel-server",
:order 15,
:status #{:started},
:deps #{"#'lotus.config/config"}}) is it not what you see? |
as to
since this is not a simple app and it would take time to debug and understand why/how and what it does. |
Hi tolitius, thanks for the reply! When it comes to I actually have found a workaround for this. Most of my states basically has "async" property in it, meaning it accept a callback to start and in the callback it calls another state like: (defn start-a!
[callback-manager]
(actually-start-a! (fn [data]
(act-on-data callback-manager data))))
(defstate b
:start (start-b!))
(defstate a
:start (start-a! @b))
This becomes a problem where it is actually calling the callback right at the start (Like (defn start-a!
[callback-manager]
(actually-start-a! (fn [data]
(act-on-data @callback-manager data))))
(defstate b
:start (start-b!))
(defstate a
:start (start-a! b))
I think this is one of those "gotchas" where a state shouldn't be accessed asynchronously. |
Is there anyway to do that? Right now accessing unstarted state in cljs will forcefully start the state, this will make the given state might start more than once and possibly in the wrong order.
The text was updated successfully, but these errors were encountered: