Skip to content

Commit 9fac2d6

Browse files
authored
Update README.md
1 parent 205aadb commit 9fac2d6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,18 @@ Functions that invoke a callback synchronously in some cases and asynchronously
1515
others create forks in the execution path that make your code less predictable.
1616
```
1717

18-
But, in Elixir, we laugh at this warning :) , because there is only one execution path
18+
Elixir is side effect free, and so the anonymous function cannot affect the context it is run in.
19+
It doesn't really matter if it is run synchronously or asynchronously. But what if you want to run it asynchronously?
20+
That's easy, just spawn a process, give it the function, and have the process send you a message when it is done.
21+
What if you don't want to wait for the answer. If you don't want to wait for the answer, then don't wait.
22+
Summary:
23+
* If you pass a function to some other piece of code, yjrm it can be run synchronously or asynchronously.
24+
* If you need an immediate result, then it's either run in-process (synchronous), or in another process, but you'll need to wait.
25+
* You decide when to wait, and what to wait for. You can ignore waiting, or combine waits, etc.
26+
* Data is immutable, so the function can't change your context that the function was created in.
27+
28+
29+
there is only one execution path
1930
for an asynchronous job: messages sent to your process which can then handle when it wants to.
2031

2132
For example, the Logger works like this in Elixir. If the backlog of things to log is

0 commit comments

Comments
 (0)