Messages API Quick Links

Messages API

It is possible to communicate between multiple app components on a page.

Builder.Messages.subscribe(type, callback)

Subscribe to receiving messages of the specified type.

Parameters

Name Type Description
type String The message type you want to subscribe to.
callback Function A function that handles receiving messages of the specified type.

Example

Builder.Messages.subscribe()

const callback = (message) => {
    console.log(message)
}


Builder.Messages.subscribe('test_type', callback)

Builder.Messages.send(type, message)

Send a message to all app components on a page.

Parameters

Name Type Description
type String The message type.
message * The message, which can be a String, Object, Number or Boolean.

Example

Builder.Messages.send() example

const message = 'This is a message from another component'


Builder.Messages.send('test_type', message)

Builder.Messages.unsubscribe(type)

Unsubscribe from receiving message of the specified type.

Parameters

Name Type Description
type String The message type you want to unsubscribe from.

Example

Builder.Messages.unsubscribe()

Builder.Messages.unsubscribe('test_type')