Vue.js Events syntax


Example

To send an event: vm.$emit('new-message');

To catch an event: vm.$on('new-message');

To send an event to all components down: vm.$broadcast('new-message');

To send an event to all components up: vm.$dispatch('new-message');

Note: $broadcast and $dispatch are deprecated in Vue2. (see Vue2 features)