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

Avatar

Avatar
Level 1
barkeraj
Level 1

Likes

0 likes

Total Posts

1 post

Correct reply

0 solutions
View profile

Avatar
Level 1
barkeraj
Level 1

Likes

0 likes

Total Posts

1 post

Correct reply

0 solutions
View profile
barkeraj
Level 1

24-02-2020

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
Level 2
Haran_Huang
Level 2

Likes

17 likes

Total Posts

54 posts

Correct reply

6 solutions
Top badges earned
Establish
Validate 1
Boost 5
Boost 3
Boost 10
View profile

Avatar
Establish
Level 2
Haran_Huang
Level 2

Likes

17 likes

Total Posts

54 posts

Correct reply

6 solutions
Top badges earned
Establish
Validate 1
Boost 5
Boost 3
Boost 10
View profile
Haran_Huang
Level 2

25-02-2020

Use direct call, which can take parameters

Answers (0)