Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Serabe committed May 16, 2024
1 parent d233a6b commit 12c0735
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,14 @@ The first element of the tuple is the live component module and the second is th
Optionally, the tuple can contain an extra first element that needs to be a PID. Though
this might not be useful in the application code (there are way better ways to send events
between processes), it is quite useful when testing. When testing a `LiveView`
it creates a new process for it. Its PID can be accessed through `view.pid`.
it creates a new process for it. Its PID can be accessed through `view.pid`.

## Why are messages without params still receiving empty params?

To normalize how to handle messages. If we could have `handle_info("message_name", _socket)`
or `handle_info({"message_name", _params}, socket)`, you would need to think about whether
the message contains params or not and then use a tuple. With this normalization, you only
care about the message name and whether you need the params or not. Also, after using similar
approaches in the past, sometimes you want to send params and sometimes you don't need to.
In cases like these, it is helpful not having a different behaviour notifying an event without
params and sending an event with _empty_ params.

0 comments on commit 12c0735

Please sign in to comment.