How do you use AlpineJS in your project? #4591
Replies: 3 comments 2 replies
-
|
I'm very curious to know about this too. I have been using alpine as the main driver behind a spa type of app. Although I think most people use it with a backend system or templating engine. So I'd be curious to see it used in practice by an experienced engineer. Thanks for starting the thread. |
Beta Was this translation helpful? Give feedback.
-
|
I've been using it for 3 years now, primarily on Shopify stores (most doing $1m/month each). Mostly end up with the component logic (data and such) in TS files that load all of them on every visit, with liquid templates handling the bindings to the UI. I don't find reusability to be an issue at all, but of course, I've touched tons of the source code directly, and maintain the types package you probably use. Don't really use classes, just plain objects, I'd be interested to know what specific issues you're running into with using classes (and if it's runtime or type level issues). What issues do you find with the toast example? I've made multiple toast systems used in production with Alpine, and they've been pretty easy to get going for the use cases. I have a WIP public Toaster package here: https://github.com/ekwoka/awesome-alpine/tree/main/packages%2Ftoasts |
Beta Was this translation helpful? Give feedback.
-
|
Hello Everyone, and @ekwoka ! First of all, thanks for maintaining the project! :) The main problem with classes was the I've ran Alpine locally, so I could debug how it works, and I saw that it creates Proxies over elements and Alpine components / stores. Most of our issues came when we started doing something in the constructor; eg. adding event listeners to something, and the callback that we pass is an anonymous function that will use a different context when it's executed, than the one that Alpine is proxied after it's initialized. This mostly resulted in a weird behaviour where the state inside class would be updated, but the template won't pick that up. But by now, we know that this was caused, because we didn't use the Also, we have noticed that Other than this, everything is fine with the classes I would say. It took us some time to figure out why the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to start this thread to educate myself on the use-cases of Alpine by other people.
Feel free to answer any of the questions that I listed below, no need to answer all if don't want to.
Questions
I will start.
Why alpine?
Technology stack
BE: Python, Flask, Jinja
FE: Alpine, Typescript, HTMX, TailwindCSS
Testing: Jest, Playwright, Flask template tests
Code organization
Alpine.dataandAlpine.strorecomponents.Challenges
objectorfunctionbased components, it is way more TS friendlier this way.anyinformation about using classes. With classes, accessing and using Magic variables is tricky, we use theAlpine.Magicsinterface to be compatible with TS.Toastcomponent, that is a part of a bigger page-wide component).Maybethis is a personal one, I'm coming from a React background, and I'm pretty used to JSX.Summary
Feel free to share any of your thoughts on the matter. I'm excited about using this tool and it would be really nice to see what's the community up to, and how you guys feel about this framework so far.
Beta Was this translation helpful? Give feedback.
All reactions