How to perform custom turbo_stream actions by Turbo::StreamsChannel

Hi,

Performing Turbo actions like replace, append or prepend through ActionCable, now as Turbo::StreamsChannel is seamlessly integrated and works great.

What would be a proper way to perform custom turbo actions as described in the turbo_power gem?

One of my tests was

                Turbo::StreamsChannel.broadcast_action_to(
                  "name-of-my-channel",
                  action:'toggle_css_class',
                  'colored-element',
                  'red'
                )

That raised

'nil' is not an ActiveModel-compatible object. It must implement :to_partial_path.

Is there a way to put the arguments the way turbo_power needs them? In the above example, based on the gem description, that would be:

turbo_stream.toggle_css_class(target, classes, **attributes)

Can such things be built on top of Turbo::StreamsChannel or do I have to build such Turbo Stream actions from scratch with Action Cable?

Why do I want this? The classic turbo functions rely on the render method, which conflicts with redirect on the same response, for example. Cable has the advantage that its independent. Together with Turbo::StreamsChannel this would be handy.

Thanks, Chris

Wrote a gem for all that: render_turbo_stream