Skip to content
Discussion options

You must be logged in to vote

You can make a magic for it. That's what we did in production for toasts.

Alpine.store('notifications', {
  notifications: [],
  add(thing) {
    this.notifications.push(thing)
  }
})

Alpine.magic('notify', () => (message) => Alpine.store('notifications').add(message))

For example.

then you can do

<button @click="$notify('Oh no')">

and

this.$notify('Oh yeah!')

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@LukeCSYello
Comment options

@ekwoka
Comment options

Answer selected by LukeCSYello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants