Vue emit
Helper function to emit events from Vue.js functional components. Can be used in regular components too. CodeSandbox demo
Installation
yarn add vue-emit# or npm install vue-emitUsage
; functional: true { return <button onClick= > contextchildren </button> ; };Params
;-
handlers_list- object of functions. In Vue this isthis.$listenersandcontext.listeners(for funtional components). Each value may be a function or an array of functions. In case of arrayemitwill call all provided callbacks. -
event_name- name of the event to fire. The event may not be defined in the handlers list: in this caseemitdoes nothing and do not throws an error (what is very handy) -
optional_payload- any amount of parameters that will be passed as arguments to the callback.