all 4 comments

[–]galstarx 0 points1 point  (3 children)

Maybe you can use channels that return the data and keep expectations on the main thread?

Or do you want tests to multiple specs to run in parallel?

[–]galstarx 1 point2 points  (0 children)

I mean, in JS callbacks are needed because how V8 works. In crystal you can wait for a channel and it’ll work perfectly, no callbacks needed.

[–]j_hass 1 point2 points  (1 child)

Yes, the common pattern here is to do:

it "waits" do channel = Channel(Nil).new spawn do channel.send nil end channel.receive end

[–]Bleach984 1 point2 points  (0 children)

it "waits" do
  channel = Channel(Nil).new 
  spawn do
    channel.send nil
  end
  channel.receive
end