This PR shores up the Turbo Streams integration in a few ways:
Unsubscribe support so someone navigating around to a bunch of pages doesn't accumulate subscriptions, keeping the websocket connection sending more than it needs to
Template tag turbo_stream_from which takes in a model instance and generates the turbo-channels-stream-source element that the frontend will use to initiate the subscription over websockets
Utilize Django's cryptographic signing capabilities to make sure that clients will only be able receive broadcasts for model instances the backend has explicitly given them access to using turbo_stream_from in a template.
Documentation for how to make use of the integration inside of documentation.md
Inspiration for the cryptographic signing as well as the API for the turbo-stream-from tag came from turbo-rails package and their Streams integration via ActionCable.
I'm very happy where this PR is so far! Like @JulianFeinauer has mentioned, I think this is good to land now and we can iterate in the API and features in different PRs.
This PR shores up the Turbo Streams integration in a few ways:
turbo_stream_from
which takes in a model instance and generates theturbo-channels-stream-source
element that the frontend will use to initiate the subscription over websocketsturbo_stream_from
in a template.documentation.md
Inspiration for the cryptographic signing as well as the API for the
turbo-stream-from
tag came fromturbo-rails
package and their Streams integration via ActionCable.