Live data from Hacker News

Stimulus.js 2.0

discourse.stimulusjs.org

71–80 of 140 posts

Re: Stimulus.js 2.0

#71
post #55

What's the difference between Pjax and Turbolinks? Just a generic version of the same thing? Could Stimulus [Reflex] be hacked to work with Django or does it have strong ties to Rails?

It's easy to use with django, I use it with some side projects:

https://github.com/danjac/localhub

https://github.com/danjac/kando

https://github.com/danjac/django-saas-starter

Re: Stimulus.js 2.0

#72
We adopted stimulusjs a couple of years ago for adding some basic interactivity on our pages and it was a decent tool, but we quickly grew out of it once we started adding more complex (form based) front-end behavior involving lots of state changes. We're currently trying to migrate a significant amount of stimulus code over to react.

Not knocking on stimulusjs, but just be wary that it does not grow well with increasing client side complexity. You'll end up writing a lot of javascript boilerplate / DOM manipulation code / custom state management components. From my experience, it's a nice lightweight tool for when you:

1. Just need to add some light interactivity (toggling visibility of components, any basic view filtering) that do not involve a lot of logic 2. Don't need j.s unit tests (stimulus has not been the most testable tool - we lean mostly on integration tests).

Re: Stimulus.js 2.0

#73

Earlier quoted context omitted.

React is great though, why not just use that?

React is great if all your frontend is React. Using it to create reusable components to sprinkle in your static HTML is overkill, and anyway it does not work with LiveView and LiveView is pretty cool. IMO React has a good data model and solid foundation, but the whole ecosystem it's relying upon is bad. I'm not a fan.

True, that’s not its use case.

Re: Stimulus.js 2.0

#74
post #52

Earlier quoted context omitted.

React supports server side rendering.

and then you need a nodejs server and sacrifices of kittens to webpack gods. Everything that libs like Stimulus aim to avoid.

Ya depends on what you’re doing. Webpack is worth mastering though in general.

Re: Stimulus.js 2.0

#75
post #51

I have great hopes that Stimulus 2.0 and Ruby 3.0 will put Rails back in the spotlight as the sane alternative to SPA abuse. Ruby and Rails have some really talented people on their teams and there's something special about the Ruby language which makes it such a fertile environment for innovation. Only Clojure compares in this respect.

Rails is dope. And it works really well with universal react rendering if you need that with react_on_rails.

Re: Stimulus.js 2.0

#76
post #52

Earlier quoted context omitted.

and then you need a nodejs server and sacrifices of kittens to webpack gods. Everything that libs like Stimulus aim to avoid.

Ya depends on what you’re doing. Webpack is worth mastering though in general.

[deleted]

Re: Stimulus.js 2.0

#77
post #54

Earlier quoted context omitted.

Rails is already the sane alternative. Any full stack framework is. DotNet, Laravel, Django, Rails... If you think you need a JS framework to handle your UI, you've already lost, and you're doomed to reinventing wheels that these technologies have already perfected.

Isn't Stimilus a JS framework?

Not really. More like super simple and light helpers for dom manipulation - lets you add interactivity with minimal trouble.

Re: Stimulus.js 2.0

#78
post #54

Earlier quoted context omitted.

Rails is already the sane alternative. Any full stack framework is. DotNet, Laravel, Django, Rails... If you think you need a JS framework to handle your UI, you've already lost, and you're doomed to reinventing wheels that these technologies have already perfected.

Isn't Stimilus a JS framework?

[deleted]

Re: Stimulus.js 2.0

#79
post #64

I worked with Stimulus for about a month and found it to be frustrating: 1. There is not a lot of documentation 2. They don't provide any testing guidelines, the best I've found is hand-wavy test-with-a-browser stuff 3. Everything is essentially global 4. Functions are disconnected from their parameters, i.e. I can't tell which bits of data a function is using without digging through a bunch of code. 5. Putting state…

Ditto. I think if you are an experienced web app dev, understand the pros and cons of something like Stimulus, and set out from the beginning of your project to make PRODUCT decisions within the constraints of something like Stimulus and being more SSR. Then it is a great tool. Anything more complicated though, and you are better off with Vue, React, Etc

I am an experienced web dev and went into Stimulus excited to have something that seemed straightforward, but was disappointed. Vue has the flexibility to do SSR HTML with a bit of javascript for behavior way that works well for me.

Just being able to put

    )">Save
Instead of:

    some--long--path-to#save" data-id="">Save
...

    save(event) {
      event.preventDefault()

In my HTML has been worth the switch for me.

Re: Stimulus.js 2.0

#80
post #54
post #51

I have great hopes that Stimulus 2.0 and Ruby 3.0 will put Rails back in the spotlight as the sane alternative to SPA abuse. Ruby and Rails have some really talented people on their teams and there's something special about the Ruby language which makes it such a fertile environment for innovation. Only Clojure compares in this respect.

Rails is already the sane alternative. Any full stack framework is. DotNet, Laravel, Django, Rails... If you think you need a JS framework to handle your UI, you've already lost, and you're doomed to reinventing wheels that these technologies have already perfected.

Thank you for saying this. I thought it but didn’t write it as I don’t want to offend.

The amount of extra work and complexity that a separate FE introduces requires serious benefits on the other side of the equation.

Post reply on HN