euvl/vue-notification

Async import of plugin

MartinMalinda opened this issue · 1 comments

Is your feature request related to a problem? Please describe.
Since notifications are often popping up later after some user interaction it makes sense to split the Notifications code from the main bundle and load it lazily so they don't delay the initial boot.

Describe the solution you'd like

I think there's two things that need to be done - I need to be able to import just the Notifications component

export default defineComponent({
  components: {
    Notifications: () => import('vue-notifications/Notifications.vue')
  }
});

vue-notification needs the wiring via Vue.notify so that would also have to be done lazily. Perhaps the Notifications.vue would check if it's set up and if not, it would do it lazily.

Alternatively, there would be a separate file, to just setup the notification emit system. That could be imported sync.

import { NotificationEvents } from 'vue-notification';

Vue.use(NotificationEvents);

This solution seems more safe because the first solution might cause an error of Vue.notify is not a function in case of a failed import, while in this case in case of a failed async import you won't have a message popped up, but at least the app won't crash.

Stale issue message