imacrayon / alpine-ajax

An Alpine.js plugin for building server-powered frontends.
https://alpine-ajax.js.org
MIT License
631 stars 12 forks source link

Calling $ajax from code outside of Alpine.js #54

Closed jonnitto closed 8 months ago

jonnitto commented 8 months ago

Currently it is not possible to call the $ajax functions outside of Alpine.js

Would it technically be possible to have exported theese functions so that they will be usable outside of Alpine.js?

imacrayon commented 8 months ago

Yeah it’s technically possible with some refactoring…The API would have to change a little bit to fill in the missing context that Alpine provides. My fear is if I expose that function there could be a lot of breakage between releases. The internals of this plugin are changing a lot, while I’m still figure out how things should work, and exposing them would mean more things that I have to track and document.

jonnitto commented 8 months ago

I solved this now by fire a custom event, and an alpine component is reacting to this… 😆

jonnitto commented 8 months ago

And, btw: Great plugin with a very nice website!

imacrayon commented 8 months ago

I solved this now by fire a custom event, and an alpine component is reacting to this… 😆

Nice! Events FTW

imacrayon commented 8 months ago

I'm going to close this out since the immediate issue is solve, however I'll still consider generalizing some of the internals. I could see that happening as we get closer to a v1 release.