11defmodule Application.Behaviour do
22 @ moduledoc """
3- This module is a convenience to define application module callbacks .
3+ Default callbacks for applications .
44
55 In Erlang/OTP, an application is a component that can be started
6- and stopped as a unit, and which can be re-used in other systems
7- as well.
6+ and stopped as a unit, and which can be reused in other systems.
87
9- The first step to achieve this is to define an application specification.
8+ The first step in creating an application is to define an application specification.
109 For example, if your application is named `:my_app`, an app specification
1110 should exist at `ebin/my_app.app`. This file is usually defined by
1211 build tools like Mix.
1312
14- Then, with the app specification in hands , we must also define an
15- application module callback that controls how to start and stop
16- such applications . This module is about defining such callbacks.
13+ With the app specification in hand , we must define
14+ application module callbacks that control how to start and stop
15+ instances of the application . This module is about defining such callbacks.
1716
18- There are two callbacks required to be implemented:
17+ There are two callbacks which must be implemented:
1918
20- 1. `start(type, args)` - It must return `{ :ok, pid }` or
19+ 1. `start(type, args)` - must return `{ :ok, pid }` or
2120 `{ :ok, pid, state }`, where `pid` is the process identifier
22- of the supervisor tree root;
21+ of the supervisor tree root and `state` is application defined
22+ state information;
2323
24- 2. `stop(state)` receives the state returned by `start` and should
25- do any necessary cleaning up. Notice that shutting down the supervisor
24+ 2. `stop(state)` - receives the ` state` returned by `start` and should
25+ do any necessary clean up. Notice that shutting down the supervisor
2626 is automatically handled by the VM;
2727
28- When using this module, it simply tags the module behaviour as
29- `:application` and defines a default `stop/1` callback. The `start/2`
30- still needs to be defined by the user.
28+ When using this module, it tags the module behaviour as
29+ `:application` and provides a default `stop/1` callback. The `start/2` callback
30+ still needs to be implemented by the user.
3131
3232 You can learn more about the `:application` module, the application
33- specification and the application module callbacks below :
33+ specification and the application module callbacks from these sources :
3434
35- http://www.erlang.org/doc/man/application.html
36- http://www.erlang.org/doc/design_principles/applications.html
37- http://learnyousomeerlang.com/building-otp-applications
35+ * http://www.erlang.org/doc/man/application.html
36+ * http://www.erlang.org/doc/design_principles/applications.html
37+ * http://learnyousomeerlang.com/building-otp-applications
3838
3939 ## Example
4040
@@ -102,4 +102,4 @@ defmodule Application.Behaviour do
102102 defoverridable [ stop: 1 ]
103103 end
104104 end
105- end
105+ end
0 commit comments