TL;DR
Code here
Intro
Snackbars, also known as alerts or toasts, are present in every application. They are handy to show im...
For further actions, you may consider blocking this person and/or reporting abuse
For those using vue and dont have Nuxt inject:
1 - Create a snackbar plugin receiving vuex store as option:
2 - At your main.js, pass your plugin to Vue:
Thanks for this. I added link for this comment on post for other people who doesn't use Nuxt.
I Set up this notifier, and it's working on the components and page, but while I try to trigger $notifier from a another plugin, the snack bar didn't shown!
You will have to search about how inject a plugin in another plugin. I'm not using Nuxt anymore, so I don't know how to solve this problem.
This is great!
Interesting way to show code with link to specific commit. It shows exactly what changed in case anyone wants to compare it with this tutorial.
One thing I instantly thought upon seeing this, "what? all those libraries just to show a snackbar?" :D Who knew the web development would become so broad!
Yeah, front end development can be complex sometimes haha.
This was the first more complex task I had to implement for one of my previous employers and which I failed miserably, precisely because I went for the naive approach to create a component and import it in every other component where I needed to spawn a snackbar. I ended polluting the entire codebase with snippets of code for the snackbar.
Thanks for sharing your approach, it's easier and more elegant.
excellent job Stephann ! important step to code reuse ! also it is possible to use this method for confirmation dialog.. which always you have to ask when you want to delete an item..
on the other hand we have three file creation and two file update for just a "snack-bar" message !
we can also use third-party library like sweetalert2. they did good job !
This was really helpful, thanks!
Also if anyone is getting this error
Property '$notifier' does not exist on type 'CombinedVueInstance<Vue...
, a workaround is to use this( this as any ).$notifier.showMessage(...)
instead.I'm having issues with the :app setting, no matter what I do it doesn't respect my footer / header etc. and just goes on top of them. :app="true" or :app="false", none of it works. Any ideas why? (Nuxt + vuetify)
Thanks a lot.
This is precisely what I'm looking for.
Amazing post !!
I was just wondering as to how we can do this without using nuxt and just plain vuejs
Did you happen to figure out how to do this?
Since nuxt was not a requirement for me. I ended up implementing it using plain vuejs and vuex
i am using nuxt. still getting this.
Uncaught (in promise) TypeError: Cannot read property '$notifier' of undefined
Thanks Stephann :)
Perfect! This is exactly what I was looking for. I liked how quasar gave this out of the box, it's a handy feature to have.
This is what exactly I was looking for, great explained 😍😍
man I love you
thank you. it's a great tutorial. I having trouble the colour doesn't work.
Thank you so much!!!
Great instruction, the ready to use functionality
Fantastic, works perfect and was well explained.