Use Event Emitters
Opened this issue · 2 comments
mykeels commented
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!
ndabAP commented
Great idea, I support it. With it, one can react immediately via $on('user-online')
.
CodebyOmar commented
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
}
}