4 ms·
How does this compare to Intercooler.js? https://intercoolerjs.org/ https://intercoolerjs.org/
by continuational 7y ago
How does this compare to Intercooler.js?
https://intercoolerjs.org/ https://intercoolerjs.org/
- rolae 7y agoIntercooler is all about getting HTML into your DOM that you get from AJAX requests without actually writing any Javascript. Alpine is more about Interactivity within the current page, without doing a request first. It keeps the state in a data object. Of course you can do similar things as you would do in Intercooler, but it would be explicit in the Javascript part. See this example they give for prefetching dropdown content from the server <div x-data="{ open: false }"> <button @mouseenter.once=" fetch('/dropdown-partial.html') .then(response => response.text()) .then(html => { $refs.dropdown.innerHTML = html }) " @click="open = true" >Show Dropdown</button> <div x-ref="dropdown" x-show="open" @click.away="open = false"> Loading Spinner... </div> </div>
- hombre_fatal 7y agoHaving used Intercooler a few times now, it feels like the worst of all worlds since you now have to write and return HTML at AJAX endpoints and keep that HTML synced with the rest of your HTML (e.g. consider CSS) instead of just returning data from an API endpoint. You end up with a bunch of made-for-Intercooler endpoints instead of thoughtful, general, data API endpoints.
- mands 7y agoWe're using intercooler on our current site and find it easier to keep the API side of the application separate from the HTML-generating MPA side. Internally they both call out to common code, but we like to keep the API-side RESTful and aren't so concerned about REST for the HTML side, both the full page views and intercooler-specific partials.
- vearwhershuh 7y agoYour general data api and your application api should be separated, since they are different concerns with different requirements, as you are discovering. Intercooler is better mentally modeled going from a traditional web application -> more interactivity rather than going from a JSON data API SPA -> an intercooler application.