I try to filterout removed items:
defp react_to_event({:delete, item}, socket) do
id = item.id
filter_by_id = fn list ->
Enum.filter(list, fn
{:id, ^id} -> false
_ -> true
end)
end
{
:noreply,
socket
|> update(:new_items, &filter_by_id/1)
|> update(:items, &filter_by_id/1)
}
end
But it seems like a lifecycle or scoping is off here: i get unused variable filter_by_id
and undefined function filter_by_id
errors here. What's wrong with the code?