Skip to content

Commit

Permalink
chore: Update README to describe subscribing via an association column
Browse files Browse the repository at this point in the history
  • Loading branch information
cheerfulstoic committed Jul 30, 2024
1 parent 7250571 commit 5bd0e37
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ You can also subscribe to individual records:
EctoWatch.subscribe(MyApp.Accounts.Package, :deleted, package.id)
```

... 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):

```elixir
EctoWatch.subscribe(MyApp.Accounts.Package, :updated, {:post_id, post.id})
EctoWatch.subscribe(MyApp.Accounts.Package, :deleted, {:post_id, post.id})
```

Once subscribed, messages can be handled like so (LiveView example given here but `handle_info` callbacks can be used elsewhere as well):

```elixir
Expand Down

0 comments on commit 5bd0e37

Please sign in to comment.