October 2019
Intermediate to advanced
358 pages
8h 22m
English
Functional programs are stateless, but we still need to be able to manage state. In Elixir, we use concurrent processes and recursion to handle this task. That may sound counterintuitive, but let’s take a look at how it works with a simple program.
To start with, let’s create a child application. From the rumbl_umbrella root directory, change to apps and create a new mix project, like this:
| | $ ➔ cd apps |
| | $ ➔ mix new info_sys --sup |
| | * creating README.md |
| | ... |
| | $ ➔ cd info_sys |
We create a brand new mix project under the apps directory. Later it will evolve into our full service, but for now let’s create a Counter server that counts up or down. Create a apps/info_sys/lib/info_sys/counter.ex ...
Read now
Unlock full access