You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to setup a simple window eventListener to go from webpage to extension. I realize that this logic for this has been abstracted inside the auto-generated file bex/content/window-event-listener.js
exportconstlistenForWindowEvents=(bridge,type)=>{// Listen for any events from the web page and transmit to the BEX bridge.window.addEventListener('message',payload=>{
...
/**** payload.data is like an object right here ****/if(payload.data.from!==void0&&payload.data.from===type){/**** payload.data is like an array right here ****/const eventData =payload.data[0],
bridgeEvents =bridge.getEvents()for(leteventinbridgeEvents){if(event===eventData.event){bridgeEvents[event](eventData.payload)}}}
...
}
The problem is that payload.data is being used both like an Array and an Object. It requires both payload.data.from and payload.data[0] to work. I got it to work by setting up my webpage like this:
I realize this is probably not the way I am supposed to setup my payload and was wondering if I am missing something or if window-event-listener.js is meant to have a different property for payload data. Thank you
The text was updated successfully, but these errors were encountered:
I now realize that the initial code was correct. The payload is a MessageEvent and it is an Object with number keys and from key too. It wasn't a mistake. Reverting changes as it broke communication completely.
I am trying to setup a simple window eventListener to go from webpage to extension. I realize that this logic for this has been abstracted inside the auto-generated file
bex/content/window-event-listener.js
The problem is that
payload.data
is being used both like an Array and an Object. It requires bothpayload.data.from
andpayload.data[0]
to work. I got it to work by setting up my webpage like this:I realize this is probably not the way I am supposed to setup my payload and was wondering if I am missing something or if
window-event-listener.js
is meant to have a different property for payload data. Thank youThe text was updated successfully, but these errors were encountered: