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

ActionCable connection created by StimulusReflex breaks after TS/AC reload #33

Closed
w1t3k opened this issue Jan 19, 2023 · 1 comment
Closed

Comments

@w1t3k
Copy link

w1t3k commented Jan 19, 2023

Really enjoy working with Hotwire and your gem as it speeds up development. Unfortunately, I run into troubles when interacting with components using StimulusReflex. Seems that gem breaks the connection used by StimulusReflex when hot-reload happens via TurboStream or ActionCable. Enforcing a full-page reload is my temporary fix for it.

Steps to reproduce:

  • gems
hotwire-livereload (1.2.2)
stimulus_reflex (3.5.0.pre9)
  • create a simple input field
<input data-reflex="change->Resources#edit_simple_field" data-gid="#{@product.to_global_id.to_s}">
  • create respective reflex
  class ResourcesReflex < ApplicationReflex

    def edit_simple_field
      @resource = GlobalID::Locator.locate element.dataset.gid
      @resource.update(element.id.underscore => element.value)

      morph :nothing
    end
  end
  • change anything on the same page as input you created
  • hotwire-livereload will do its job and change the view
  • enter new value for input and click away
  • SR magic will fire
  • refresh the page manually, it will show old value in input field
  • consecutive updates of input values will result in proper behavior, but only because we did manual full reload of the page

For now, I am resolving this with enforcing automatic full reload that library allows
config.hotwire_livereload.force_reload_paths << [] but would be great if there would be a way to make it work the old way. Appreciate any suggestion, on how I could approach a described problem.

@kirillplatonov
Copy link
Owner

Hotwire Livereload uses separate ActionCable server now. This should fix the issue:
#69

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

No branches or pull requests

2 participants