logoalt Hacker News

evncyesterday at 2:57 PM2 repliesview on HN

Interesting. Does that mean if you want to say, make an asynchronous http request, you do something like “fire_event(HttpRequestEvent(…))” which returns immediately, and somewhere else define a handler like “on_event(HttpResponseEvent, function (event) { … })” ? So you kind of have to manually break your function up into a state machine composed of event handlers? How do you associate a given HttpResponseEvent with a specific HttpRequestEvent?


Replies

travisgriggsyesterday at 4:44 PM

Elixir IS very state machine like.

So yes, your event loop processes the results of asynchronous work launched because of earlier events the same way.

Part of what makes this work, is the awesome function clause matching. Coordinating origin of async work and result of async work is really easy because you can match on any form of terms your heart desires, and everything is always immutable.

koakuma-chanyesterday at 4:37 PM

Isn't that just callback

show 1 reply