Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

"A message" struct w/ four required keys: from, to, subject, body

Notifications You must be signed in to change notification settings

amorphid/a_message

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AMessage

"A message" is an Elixir struct w/ four required keys:

  • to
  • from
  • subject
  • body

Um... isn't this kind of useless?

Probably :)

Some of us developers have trouble crafting messages with meaningful semantics, especially when the message is doing something mundane & generic.

# what is the some_pid?
# why is it being updated?
# what's in some_data?
# I don't understand.  At all.
send(some_pid, {:update, some_data})

By using AMessage, maybe it'll be easier for you to capture some of the essence of what you're trying to accomplish, giving someone else (maybe you at a later time) enough context to come up with more meaningful semantics at a later date.

# OK, I see this module is sending updated endpoints to SomeModule
# What the heck is this AMessage ridiculousness?
# A more meaningful abstraction might be... <conversation happens>
# Try this => send(endpoints_repo, {:update, endpoints})
# Even better => EndpointsRepo.update(repo_pid, endpoints)
send(some_pid, %AMessage{from:    __MODULE__,
                         to:      EndpointsRepo,
                         subject: :update_endpoints},
                         body:    endpoints})
```

## Add it (to mix.exs)

```elixir
def deps do
  [{:a_message, "~> 1.0.0"}]
end
```

About

"A message" struct w/ four required keys: from, to, subject, body

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.