1.0.2 • Published 5 years ago

vue-meteor-error-notifier v1.0.2

Weekly downloads
5
License
ISC
Repository
github
Last release
5 years ago

Vue-Meteor Error Notifier

A utility for formatting error objects passed down from Meteor to the client into a user friendly notification. Supports native alert() notifications, as well as Buefy and Vue-Sweetalert2 toast notifications.

Install

npm install vue-meteor-error-notifier

Import

import Vue from 'vue';
import VueMeteorErrorNotifier from 'vue-meteor-error-notifier';

// Make sure this is placed after Vue.use(Buefy) or Vue.use(VueSweetalert2)
Vue.use(VueMeteorErrorNotifier, {
    notifier: 'sweetalert2' // Can be one of 'native', 'sweetalert2' or 'buefy'
});

Use

export default {
    methods: {
        someVueMethod() {
            Meteor.call('some.meteor.method', (err, resp) => {
                if (err) {
                    this.$notifyError(err); // Formats and spits out a user friendly error notification
                    return;
                }
               
                // Continue method here
            });
        }
    }
}

Notification Interfaces

Errors can be emitted using either native alert() notifications, or using a pre-existing notification library like the Toast notifications bundled with Buefy or Sweetalert's Toast notifications.

As native alert() notifications blocks the user interface until input is received from the user, I'd recommend using installing (if not already installed) either Buefy or Vue-Sweetalert2. Then specify the interface you want to use in the Vue.use() options specified above.

License

This repository is licensed under the ISC license.

Copyright (c) 2019, Jørgen Vatle.