-
Notifications
You must be signed in to change notification settings - Fork 15
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
WIP: Allow users to control which groups a client is added to #7
base: master
Are you sure you want to change the base?
Conversation
|
||
subscription = """ | ||
await asyncio.sleep(0.01) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need it? It looks like we didn't need before.
@jaydenwindle Will this get released any soon? This will come handy in a project I am working on. |
Hey @oldani! Yes, I'm planning to merge this PR and release v2 as soon as I get a chance to write a v1 -> v2 migration guide for the docs, since there are several breaking changes. I've been a bit busy with other projects recently so haven't had time to finish it. If you'd like to help with the migration guide I'd definitely accept a PR! |
This PR fixes #6 by allowing users to manually control which Channel Layers groups a subscribed client is added to, and which groups subscription events are broadcast over.
The consumer instance is now passed to each subscription resolver as a the
root
value, and exposes a function calledsubscribe
. When called, this function will add the currently connected client to the specified group and return anObservable
of all values sent to that group.A model mixin called
SubscriptionModelMixin
has been created, which usesdjango-lifecycle
instead of Django signals to automatically trigger subscription events when model instances are created, updated, or deleted.This PR also removes the legacy
SubscriptionEvent
andModelSubscriptionEvent
classes, and removes the defaultpost_save_subscription
andpost_delete_subscription
signal handlers, as they are no longer used.Example:
This PR also fixes #8 and #2.