Events (incomplete)
$emit(eventName, data = undefined)
The method emits the event with the given eventName and data
Example:
Buddi.$emit('customer:logged-in', {email: 'john@doe.com', …})
$on(eventName, callback, listenerKey = null)
The method subscribes for the event with the given eventName.
Params:
listenerKey - Optional. Allows to unsubsribe easier.
Example:
Buddi.$on('customer:logged-in', ({email}) => {
alert("Hello " + email);
}, 'customerLoggedInListener')
$off(eventName, callbackOrListenerKey)
This method removes the previously registered subscription for an event with the given eventName. eventName can be an array or values. If array - will unsubscribe from all the events in the array
Params:
callbackOrListenerKey - You can either pass the callback which was used to register the subscription for the event OR the listener key which was used to register the subscription for the event.
Example:
Buddi.$off('customer:logged-in', ({email}) => {
alert("Hello " + email);
})
OR
Buddi.$off('customer:logged-in', 'customerLoggedInListener')