Created
June 27, 2017 09:36
-
-
Save myobie/621c93f86d6d9d6c52b4bfb9a6378c57 to your computer and use it in GitHub Desktop.
An example of how users and lists could know about each other
This file contains hidden or 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 User do | |
| use Highlander.Object, type: :user | |
| defobject name: "", email: "", known_lists: [] | |
| end | |
| defmodule List do | |
| use Highlander.Object, type: :list | |
| defobject title: "", todos: [], allowed_users: [] | |
| def handle_update({:insert_todo, list, todo, user}, state) do | |
| if Enum.any?(list.allowed_users, | |
| fn id -> id == user.id end) do | |
| %{todos: [todo | state.todos]} | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment