NilCoalescing / djangochannelsrestframework

A Rest-framework for websockets using Django channels-v4
https://djangochannelsrestframework.readthedocs.io/en/latest/
MIT License
603 stars 84 forks source link

[Feature] Subscribe to changes of a given field/fields #181

Open hishnash opened 1 year ago

hishnash commented 1 year ago

In some situations we only want to subscribe to changes of a given field on our models. And do not what to get a load of notifications for other fields.

Describe the solution you'd like

In the django signal we should be able to extract the set of dirty fields on save of the model. This can be used to build a dynamic set of group names.

We can then expose a subscribe to field method were consumers can add subscription to fields so that they are notified when given fields change.

Such field change groups would be appended to the groups emitted by the the groups for consumer a groups for signal methods so that users could still use the current filtering method in conjunction with field observation.

We would need a new @ModelFieldObserver() with some way to declare what fields to automatically generation groups for.