turbo_response.channel_helper
#
Module Contents#
Functions#
|
Generate stream_name from a list of objects or a single object. |
|
Generate signed stream key from stream_name |
|
Verify signed stream key |
|
This function help render HTML to Turbo Stream Channel |
Attributes#
- turbo_response.channel_helper.signer#
- turbo_response.channel_helper.stream_name_from(streamables)#
Generate stream_name from a list of objects or a single object.
- Parameters:
streamables (Union[List, object]) –
- Return type:
str
- turbo_response.channel_helper.generate_signed_stream_key(stream_name)#
Generate signed stream key from stream_name
- Parameters:
stream_name (str) –
- Return type:
str
- turbo_response.channel_helper.verify_signed_stream_key(signed_stream_key)#
Verify signed stream key
- Parameters:
signed_stream_key (str) –
- Return type:
Tuple[bool, str]
- turbo_response.channel_helper.broadcast_render_to(streamables, template, context=None)#
This function help render HTML to Turbo Stream Channel
for example, in Django template, we subscribe to a Turbo stream Channel
{% turbo_stream_from ‘chat’ view.kwargs.chat_pk %}
Then in Python code
- broadcast_render_to(
[“chat”, instance.chat_id], template=”message_append.turbo_stream.html”, context={
“instance”: instance,
},
)
- Parameters:
streamables (Union[List, object]) –
template (str) –