Call broadcast function from app configured module.

This commit is contained in:
Pim Kunis 2019-08-24 16:01:49 +02:00
parent d6e877137f
commit fc54fa1761
7 changed files with 15 additions and 22 deletions

View file

@ -30,7 +30,11 @@ defmodule Morse.Server do
@impl true
def handle_cast({:progress, new_progress}, {pid, _progress}) do
GenServer.cast(Ui.SocketAPI, {:broadcast_progress, new_progress})
apply(progress_socket(), :broadcast_progress, [new_progress])
{:noreply, {pid, new_progress}}
end
defp progress_socket do
Application.fetch_env!(:morse, :progress_socket)
end
end

View file

@ -49,7 +49,7 @@ defmodule Morse.Worker do
Process.sleep(@sleep_delay)
end
defp signal_symbol(_gpio, {? , index}, length) do
defp signal_symbol(_gpio, {?\s, index}, length) do
Process.sleep(@sleep_pause)
update_progress(index, length)
end