April 2019
Beginner to intermediate
244 pages
6h 34m
English
We’re almost there. We’ve added the dependencies, defined our repository, and configured it. The last step is to ensure the repository is started when the application starts. To do this, we need to add the repository to the application supervision tree.
If your project was generated with mix new --sup you should have a file lib/my_app/application.ex with the following function:
| | def start(_type, _args) do |
| | # List all child processes to be supervised |
| | children = [ |
| | # Starts a worker by calling: MyApp.Worker.start_link(arg) |
| | # {MyApp.Worker, arg}, |
| | ] |
| | |
| | # See https://hexdocs.pm/elixir/Supervisor.html |
| | # for other strategies and supported options |
| |
Read now
Unlock full access