Elixir foundationSort Order

Elixir: Completing Rendering Status Checking - [023]

We'll finish off the rendering status checking in this episode. First let's start with setting the initial state for the rendering status.

Initial Render State

# ...def init(url) do  # ...  {:ok, %{     # ...    valid: false,    completed: false  }}end

We need to add the 2 initial states we will use to track the rendering status.

Next we'll need to update these states based on the message we receive from the status checker.

Updating the State

Remove all the previous code for the :completed_and_valid, all we will do here is update the state of our render engine.

def handle_info(:completed_and_valid, state) do  {:noreply, Map.merge(state, %{ completed: true, valid: true }) }end

We'll need to to the same for the :completed state

def handle_info(:completed, state) do  {:noreply, Map.merge(state, %{ completed: true }) }end

Notice that we're not marking the :valid as true in the second handle_info.

That's pretty much it, in the next episode we will take a look at how we can read these states and actually output the html.