a() -> ... X = read(), ... Y = read(), ... write(...), ...
read() -> receive Pattern1 -> ... Pattern2 -> ... end.
... X = read() ...
var done = function(x){ ... do something with x ..}; var error = function(x){ .... x ...} read(Something, {onSuccess:done, onError:error}); ... ... more code ...
loop(F) -> receive {new_callback, F1} -> loop(F1); Msg -> F(Msg), loop(F) end.