hotwired / turbo

The speed of a single-page web application without having to write any JavaScript
https://turbo.hotwired.dev
MIT License
6.65k stars 421 forks source link

[Feature Request] Custom actions for streams #247

Closed gabriel-curtino closed 2 years ago

gabriel-curtino commented 3 years ago

It may be useful to send custom actions by turbo streams like this:

<turbo-stream action="reload" target="frame_id">

which I'm currently using for reloading frames with an src attribute as response to certain actions.

So far this is the only case I had to implement but, in order to avoid an overload of possible new stream actions, I think a small implementation where turbo receives a stream with a custom action and triggers an custom event over the target element can make a difference covering any possible case.

target_element.dispatchEvent(new CustomEvent('action_name'))

It is just an idea!

seanpdoyle commented 2 years ago

Is this closed by https://github.com/hotwired/turbo/pull/479?

gabriel-curtino commented 2 years ago

I think so! It offers a way to manage custom actions. Thanks!

seanpdoyle commented 2 years ago

That's great news! Would you mind closing this issue to reflect that fix?