Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: subscribe_uniq/3 #159

Closed
wants to merge 1 commit into from

Conversation

mad42
Copy link

@mad42 mad42 commented Jun 30, 2021

I've recently encountered edge cases when I subscribe to an already subscribed topic, multiplying received events.
subscribe_uniq/3 prevents this from happening by looking up in the Registry for pubsub, topic before registering it.

@chrismccord
Copy link
Member

This will only allow a single subscriber for any process, so this is not what you want. Note the docs on duplicate subscriptions:
https://github.com/phoenixframework/phoenix_pubsub/blob/master/lib/phoenix/pubsub.ex#L98-L104

The best solution is to avoid duplicating the subscribe in the caller, such as checking your state. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants