Skip to content

Commit 5bd0e37

Browse files
committedJul 30, 2024
chore: Update README to describe subscribing via an association column
1 parent 7250571 commit 5bd0e37

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
 

‎README.md

+7
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ You can also subscribe to individual records:
5555
EctoWatch.subscribe(MyApp.Accounts.Package, :deleted, package.id)
5656
```
5757

58+
... OR you can subscribe to records by an association column (but the given column must be in the `extra_columns` list! See below for more info on the `extra_columns` option):
59+
60+
```elixir
61+
EctoWatch.subscribe(MyApp.Accounts.Package, :updated, {:post_id, post.id})
62+
EctoWatch.subscribe(MyApp.Accounts.Package, :deleted, {:post_id, post.id})
63+
```
64+
5865
Once subscribed, messages can be handled like so (LiveView example given here but `handle_info` callbacks can be used elsewhere as well):
5966

6067
```elixir

0 commit comments

Comments
 (0)