Skip to content

Conversation

@yrashk
Copy link
Contributor

@yrashk yrashk commented Feb 16, 2022

Recently, an ability to customize a channel has been added (#264).

However, it's still quite rigid as we can't pass any contextual information
from the client-side. This can be very useful when, for example, there's a need
to indicate the state of the page for the initial burst of messages upon
subscription.

Solution: allow passing additional parameters through data- attributes

This integrates nicely with turbo_stream_from helper which will be able
to process data: {...} attributes to pass them to the custom element.

turbo-cable-stream-source implementation has been updated to take these
dataset attributes into account and pass them along upon subscription.


Supersedes #269

Recently, an ability to customize channel has been added (hotwired#264).

However, it's still quite rigid as we can't pass any contextual information
from the client side. This can be very useful when, for example, there's a need
to indicate state of the page for the initial burst of messages upon
subscription.

Solution: allow passing additional parameters through `data-` attributes

This integrates nicely with `turbo_stream_from` helper which will be able
to process `data: {...}` attributes to pass them to the custom element.

`turbo-cable-stream-source` implementation has been updated to take these
dataset attributes into account and pass them along upon subscription.
@yrashk
Copy link
Contributor Author

yrashk commented Feb 16, 2022

CI failures seem to be unrelated to the change itself. I will happily accept any guidance to get them bent back in shape ;)

@yrashk
Copy link
Contributor Author

yrashk commented Feb 23, 2022

Any chance this can be reviewed/opined on? cc @dhh

Thank you!

@quadule quadule mentioned this pull request Mar 13, 2022
@dhh dhh merged commit 395fef0 into hotwired:main May 3, 2022
dhh added a commit to ankurp/turbo-rails that referenced this pull request May 22, 2022
* main: (175 commits)
  Support `[formmethod]` overrides to `_method` (hotwired#239)
  call ActionView::RecordIdentifier.dom_id explicitly (hotwired#333)
  removed a handful of extra 'the' in method descriptions (hotwired#334)
  Fix missing `activejob` dependency (hotwired#331)
  Document the turbo_frame_tag helper with multiple arguments (hotwired#329)
  Add possibility to nest turbo frames (hotwired#296)
  Fix breaking in non-Zeitwerk environment (hotwired#304)
  Problem: inability to pass additional parameters to stream channels (hotwired#308)
  Fix CI with Rails main (hotwired#314)
  add targets to assert_{,no_}turbo_stream (hotwired#321)
  fix tests for rails 7.0 (hotwired#320)
  Test on Rails 7.0
  Use where on Windows instead of which (hotwired#299) (hotwired#300)
  Bump version for 1.0.1
  Upgrade @rails/actioncable to 7.0.1
  Bump @rails/actioncable dependency to ^7.0
  Add Turbo::Broadcastable support for #broadcast_render and #broadcast_render_to (hotwired#298)
  fix a little typo for wrong constant name (hotwired#290)
  Bump version for 1.0.0
  Make clear this is included by default in Rails 7
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants