CodebyOmar/vue-network

Use Event Emitters

Opened this issue · 2 comments

Rather than hide and show an HTML element, could you trigger an event on the Vue component, or an event-bus when network status changes?

This would make your component template and style agnostic, which is good!

Great idea, I support it. With it, one can react immediately via $on('user-online').

That is why i made displaying the HTML element optional, you can disable it. There is also a global variable that you can actually watch in any of your components this.$isOnline , with this you can do something like this;

watch : {
    "$isOnline": function (val) {
        //doSomething whenever the network status changes
    }
}