Vuetify: [Feature Request] Bind Snackbar to Vue prototype as a function

Created on 12 Dec 2017  路  3Comments  路  Source: vuetifyjs/vuetify

New Functionality

Snackbar, toast, notification and dialog as the messaging components are used frequently in development, which should be bound to vue prototype as a function, like element-ui. For example:

Vue.prototype.$message = function(msgType, position, color, content, ifShowClose, timeout) {
  //msgType = 'v-snackbar' || 'v-dialog' || ...
}

Improvements

So developers can give out a message easily by:

this.$message('v-snackbar', 'top', 'error', 'Bad response from server', true, 3000)

Bugs or Edge Cases it Helps Avoid

none

duplicate

Most helpful comment

@KaelWD Thanks a lot for the reply. I don't know exactly how you plan to design this message queue, but not all Vue.js projects use something like Vuex to share and store data. Even if in the message queue, developers should not add <v-snackbar> manually to every route-component / component / page, because almost everyone of them needs to deal messaging. I think binding it to Vue.prototype is an easy way to realize the expectation. Don't make it too complicate to use. PS: I agree that there should be only one snackbar shown in the same time.

All 3 comments

Technically a duplicate of #2384

This won't be on the vue prototype, but we may implement a message queue in the snackbar component itself so you can manage them with something like Vuex.

@KaelWD Thanks a lot for the reply. I don't know exactly how you plan to design this message queue, but not all Vue.js projects use something like Vuex to share and store data. Even if in the message queue, developers should not add <v-snackbar> manually to every route-component / component / page, because almost everyone of them needs to deal messaging. I think binding it to Vue.prototype is an easy way to realize the expectation. Don't make it too complicate to use. PS: I agree that there should be only one snackbar shown in the same time.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please direct any non-bug questions to our Discord

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Webifi picture Webifi  路  3Comments

paladin2005 picture paladin2005  路  3Comments

SteffenDE picture SteffenDE  路  3Comments

itanka9 picture itanka9  路  3Comments

Antway picture Antway  路  3Comments