component

2016-07-08T17:07:10.000082Z

I have a ClojureScript component, where start performs some async IO, obviously I can’t block the thread waiting for this to happen like I can on the JVM, so a component that depends on this one has no way to wait for start to happen. Anyone know of any solutions to this? I could imagine an async extension to component using promises or something like that, so that the start order/timing of start/stop is respected in a non-blocking environment.

stuartsierra 2016-07-08T17:17:45.000085Z

@keeth I think the general approach would be to create asynchronous promise-like things and assoc them into your components in their start methods. Other components which need to start subsequently will have to use some kind of promise chaining.

stuartsierra 2016-07-08T17:18:26.000086Z

Component was not designed with ClojureScript in mind, so it may not be an ideal solution.

2016-07-08T17:26:34.000088Z

@stuartsierra: thanks, yep that’s more-or-less what i have done, assoc’d a ready? key which returns a promise. thinking of maybe having these components implement an additional protocol with methods like started and stopped which return promises.