dollarshaveclub / postmate

📭 A powerful, simple, promise-based postMessage library.
MIT License
1.86k stars 184 forks source link

[Feature Request] Ability to Configure maxHandshakeRequests as an option to Postmate constructor #240

Open Drew-Daniels opened 1 year ago

Drew-Daniels commented 1 year ago

What Is the issue?

I would like for the ability to configure the maximum number of handshake requests the Parent window sends to the child - as the default of 5 seems to introduce some unnecessary rigidity.

Provide issue context below using code examples, images, or links


For my use case, I have two React apps, where, the embedded iFrame React app takes a few seconds to render, and once it has finished rendering, the parent React app has already sent all 5 handshake requests, and stops sending any more requests.

It would be nice, if for scenarios like mine, I would be able to override the default of 5 when I instantiate the Postmate object in the Parent window:

const handshake = new Postmate({
  container: document.getElementById('iframe-container'),
  url: IFRAME_URL,
  name: 'embedded-iframe',
  classListArray: ['embedded-iframe'],
  maxHandshakeRequests: 20,
})

Read about references issues here. Provide paragraph text responses to each header.