Skip to content

Commit 1c20407

Browse files
author
kidp330
committed
Update source after start.exs fix
1 parent 84e2c13 commit 1c20407

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

basic_pipeline/03_Source.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ defmodule Basic.Elements.Source do
7474
...
7575
@impl true
7676
def handle_init(_context, options) do
77-
{[setup: :incomplete],
77+
{[],
7878
%{
7979
location: options.location,
8080
content: nil
@@ -85,7 +85,7 @@ end
8585
```
8686

8787
As said before, `handle_init/2` expects a structure with the previously defined parameters to be passed as an argument.
88-
All we need to do there is to initialize the state - our state will be in a form of a map, and for now on we will put there a `location` (a path to the input file) and the `content`, where we will be holding packets read from the file, which haven't been sent yet. For now, the content is set to nil as we haven't read anything from the input file yet. That's also why we send back the action `setup: :incomplete`. In the next section we'll talk about more involved initialization and resources managed by our element.
88+
All we need to do there is to initialize the state - our state will be in a form of a map, and for now on we will put there a `location` (a path to the input file) and the `content`, where we will be holding packets read from the file, which haven't been sent yet. The recommended approach is to keep `handle_init/2` lean and defer any heavier initialization to `handle_setup/2` which runs automatically afterwards, if defined. In the next section we'll talk about more involved initialization and resources managed by our element.
8989

9090
> ### TIP
9191
>
@@ -94,8 +94,7 @@ All we need to do there is to initialize the state - our state will be in a form
9494
9595
## Preparing our element
9696

97-
When an element requires more time to initialise, you should delegate complex tasks to `handle_setup/2`. This callback runs after `handle_init/2` if it returns the `setup: :incomplete` action.
98-
In our example, we'd like to open, read and save the contents of the input file. We then save it in our state as `content`.
97+
In the `handle_setup/2` callback, we'd like to open, read and save the contents of the input file. We then save it in our state as `content`.
9998

10099
**_`lib/elements/source.ex`_**
101100

0 commit comments

Comments
 (0)