Fork me on GitHub
#core-async
<
2016-01-29
>
tap08:01:05

I’m using core.async on node, creating a command line app. Is there a way block node to not to quit before a certain go block finish executing?

ragge11:01:07

@tap: I've never used core.async with node, but go blocks return a channel so you could possibly do a take on the go block you want to wait for

ragge11:01:41

@tap: (<! (go (do-stuff ...)))

ragge11:01:30

@tap: (value taken will be whatever the go block returned, which is quite neat)

tap11:01:26

@ragge: The outer take (<!) will need to be wrapped with an another go block so it’s same thing

ragge11:01:12

@tap: I'm probably missing something around the node execution semantics then...

ragge11:01:40

@tap: you could use take! I guess...

ragge11:01:01

@tap: but there's probably a correct way to do this that someone who has used core.async on node can tell you

tap11:01:53

@ragge: take! is also asynchronous though

tap11:01:16

Maybe I should explain more. I’m making a command line script with Node. The problem is the script terminates too fast. One of my go block didn’t have a chance to execute.

tap11:01:08

Usually on jvm, I can make main thread wait with <!!. But I don’t know the way to wait like that in clojurescript

tap11:01:55

@ragge: Thanks, anyway!

sander19:01:20

@tap I think I solved that once by adding a (js/setInterval (fn []) 10000) to my script

sander19:01:47

node will terminate unless there's something on the event queue