Any way to have an Event Type be postMessage, or must that be Custom Code? | Community
Skip to main content
February 24, 2020
Solved

Any way to have an Event Type be postMessage, or must that be Custom Code?

  • February 24, 2020
  • 2 replies
  • 3073 views

Our dev group have found benefits in using the `postMessage` event as a great way to do pub/sub type communication. We'd love to use it in Launch, but don't see a way to make it work outside of Custom Code.  Is Custom Code the only way to do it?

 

It would be great to have an Event Type where we could select `postMessage` and then be asked for a string for it to look for inside of a data, so `siteEventName` in the example below. The data name would need to be standardized on, or also make that something which is configurable when setting it up.

 

 

// equivalent custom code window.addEventListener( "message", function(event) { if (event.data.type === "siteEventName") { trigger(); } }, false ); // what we would fire in our site code to trigger the event to fire window.postMessage( { type: "siteEventName" }, "*" );

 

 

Even better would be to make the additional portions of the data sent to the `postMessage` available to the rule as another Data Type

 

 

window.postMessage( { type: "siteEventName", foo: "bar", hello: "world" }, "*" );

 

 

So `foo` and `hello` could be available within a new `postMessage` data type #dreamBig

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Haran_Huang

Use direct call, which can take parameters

2 replies

Haran_Huang
Haran_HuangAccepted solution
Level 4
February 25, 2020

Use direct call, which can take parameters

jantzen_b
Adobe Employee
Adobe Employee
September 15, 2020
Do any of the answers below answer your initial question? If so, can you select one of them as the correct answer? If none of the answers already provided answer your question, can you provide additional information to better help the community solve your question?