Alpine: Fire events after load, update, reload, etc

Created on 4 Mar 2020  路  3Comments  路  Source: alpinejs/alpine

I think this would be useful for anyone who wants to hook into Alpine from outside of their components, possibly inside of a scoped JS file.

I have a working branch for this, using the dispatch() function from Livewire. I'm also working on a devtools panel for alpine and this would be super useful so I don't have to mess around with more Proxies etc, cc/ @calebporzio

enhancement

Most helpful comment

After some dispute on the events that should be fired, to begin with I'm going to keep the list short:

The transition based events will be fired on the element that is actually transitioning. The event will be bubbled up to the parent component too, as per JavaScript behaviour so the event can be listened to there.

The alpine:loaded event will be fired at the document level after all of the components have been initialised and observation have started.

Any more ideas for events are welcome below.

All 3 comments

After some dispute on the events that should be fired, to begin with I'm going to keep the list short:

The transition based events will be fired on the element that is actually transitioning. The event will be bubbled up to the parent component too, as per JavaScript behaviour so the event can be listened to there.

The alpine:loaded event will be fired at the document level after all of the components have been initialised and observation have started.

Any more ideas for events are welcome below.

Closing this issue for now, since this will probably be re-evaluated for v3.

This is exactly what's needed for something like sequential animations, instead of trying to fake it with animation delays.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikemartin picture mikemartin  路  3Comments

piotrpog picture piotrpog  路  3Comments

imliam picture imliam  路  5Comments

adinata-id picture adinata-id  路  4Comments

allmarkedup picture allmarkedup  路  4Comments