Hacker News new | past | comments | ask | show | jobs | submit login

My goal is to write a demo app with:

- Rails

- StimilusReflex

- view_component (https://github.com/github/view_component)

- Web components

With these 4, it divides responsibilities very cleanly/pragmatically: Rails is your app framework. view_component is how you divide your view into an organized/flexible structure. StimilusReflex is the "reflexive" bridge between the 2.

What happens when you need just a sprinkle of javascript to re-render a component when websockets/StimilusReflex are too slow (ie: user interacting with a color picker or something)? You could use Stimilus.js to sprinkle this interactivity... BUT you might end up with duplication between your view_components and your Stimilus.js controller. If you use webcomponents, then you can follow the open/closed rule: Your view_component can only interact with your custom webcomponent and then your webcomponent knows how to render/re-render those custom bits. So it doesn't matter if that webcomponent is rendered from: initial page load, StimilusReflex, or rapid js events (before they are throttled to StimilusReflex), it's all goes through the webcomponent "front door".




If you’re going to use view components, maybe check this out: https://github.com/unabridged/motion


I've been thinking about this setup a lot but never have time to try it. Is there somewhere I can follow to be notified when you accomplish this?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: