Created
July 17, 2020 11:02
-
-
Save benvp/f5b8c5710d735404e6d1a3b4bda564a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Autocomplete.Items do | |
@items [ | |
%{id: 1, name: "Item 1", image_url: "images/items/1.png"}, | |
%{id: 2, name: "Item 2", image_url: "images/items/2.png"}, | |
%{id: 3, name: "Item 3", image_url: "images/items/3.png"}, | |
%{id: 4, name: "Item 4", image_url: "images/items/4.png"} | |
] | |
def list_items() do | |
@items | |
end | |
def get_item(id) do | |
Enum.find(@items, &(&1.id === String.to_integer(id))) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment