Calling external APIs from Hologram

Good to know, thanks! I’m seeing a repeating pattern where an action needs to be created to accept changes from a command.

def command(:fetch_todos_async, _params, server) do
  ...
  put_action(server, :add_todo, todo: todo)
end

def action(:add_todo, %{todo: todo}, component) do
  put_state(component, :todo, todo)
end

Would it make sense to have a function that facilitates that automatically, or maybe an anonymous function? Or does that feel too magical?

def command(:fetch_todos_async, _params, server) do
  ...
  update_state(server, todo: todo)
end
2 Likes