Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to use turbo-stream over existing turbo channel websocket #22

Merged
merged 5 commits into from
May 30, 2022

Conversation

tleish
Copy link
Contributor

@tleish tleish commented May 26, 2022

closes #21

A few changes here.

turbo-stream reload method

With these changes you can now reload the page using the turbo channel by sending a turbo-stream to the client by setting:

config.hotwire_livereload.reload_method = :turbo_stream

Note: :action_cable is the default value.

This allows the gem to be used with AnyCable and JWT identification, however it can also be an option with just ActionCable.

When enabling the turbo-stream option:

  • No hotwire-livereload ActionCable channel is created
  • A different partial is rendered from the hotwire_livereload_tags helper
  • A different JS file is loaded

Extracted Shared JS Code

This PR extracts some shared javascript into a separate file to be used with either option.

Turbo.visit action: replace

This PR also includes a change with reloads the page without advancing the history.

- Turbo.visit(window.location.href);
+ Turbo.visit(window.location.href, { action: "replace" });

@kirillplatonov
Copy link
Owner

Great workaround for AnyCable 👍

@kirillplatonov kirillplatonov merged commit ee28fc1 into kirillplatonov:main May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support AnyCable with JWT
2 participants