Events
#
SubscribeTo subscribe to an event use the .subscribe()
method which accepts two arguments.
eventName
(string)callback
(function) with an argument of provided data (if there is).
Available event names:
layoutChange
- will be called on layout change (Default, Blank, Header and Footer),data
of the layout will be provided as an argument of the callback function.
Example:
window.vcwbEditorApi.subscribe('layoutChange', (data) => { console.log('layout has changed', data)})
elementUpdate
- will be called on existing element update,id
andelement
provided as an argument of the callback function.
Example:
window.vcwbEditorApi.subscribe('elementUpdate', (id, element) => { console.log('element has updated', id, element)})
savedDataLoad
- will be called on post/page load after data is received,data
object that was saved will be provided as an argument of the callback function.
Example:
const handleSavedDataLoad = (data) => { if (data.exampleInsights) { console.log(data.exampleInsights) }}
window.vcwbEditorApi.subscribe('savedDataLoad', handleSavedDataLoad)
#
UnsubscribeTo unsubscribe from an event use the .unsubscribe()
method which accepts two arguments.
Arguments:
eventName
(string)callback
(function) that was previously subscribed.
Example:
const handleSavedDataLoad = (data) => { if (data.exampleInsights) { console.log(data.exampleInsights) }}
window.vcwbEditorApi.unsubscribe('savedDataLoad', handleSavedDataLoad)