hotwire-django / turbo-django

Unmaintained // An early stage integration of Hotwire Turbo with Django
https://discuss.hotwire.dev/t/django-backend-support-for-hotwire/1570/
Other
385 stars 20 forks source link

Update Turbo Stream integration to use model based streams #6

Closed davish closed 3 years ago

davish commented 3 years ago

This PR updates the BroadcastableMixin and TurboStreamsConsumer to bundle all updates for a given model into a single stream rather than require separate stream subscriptions to accomplish this.

This brings our BroadcastableMixin in line with the Broadcastable found in turbo-rails. A few options now can be set on a model which inherits from BroadcastableMixin:

One important TODO for another PR is allowing a custom template for a model. Right now it defaults to using app/model.html which is fine for demos but real applications should be able to customize this. Potentially even have this be a per-subscription option.

The chat demo has also been updated to include editing the room title in-line, just like the Hotwire video demo. Any feedback on either the code or the updated demo is appreciated!