Hello everyone,
I've written SIP server and library in Scala and like in any network/server type code, in a lot of places i'm having to write nested callbacks which can look quite ugly:
obj.connect( "some parameters", ()=>
obj2.connect("more parameters"), ()=>
obj3.connect("even more"), ()=>
println("everone connceted"))))
so it occurred to me I could (arguably) make it a bit neater by using for comprehension. Then it occurred to me there may already be an idiomatic "scala" way of doing this, and I shouldn't reinvent the wheel if so.
Here's what I whipped up as an example of the kind of thing I want to do. Obviously, instead of a sleep I'd be actually sending the whole method off to an actor which would do some stuff, and the callback would occur in another thread...
--Vincent