Aaronius / penpal

A promise-based library for securely communicating with iframes via postMessage.
MIT License
399 stars 56 forks source link

Types for the response of Promise returned after connection established #72

Closed rizikolik closed 2 years ago

rizikolik commented 3 years ago
connection.promise.then((child ? Type ?? ) => {
  child.multiply(2, 6).then((total) => console.log(total));
  child.divide(12, 4).then((total) => console.log(total));
});

Here I have some methods that my child provides.And I want to include that methods inside this child.I want to use a new interface that will look like something like this:

interface Child extends<PenpalChildType> {
...some custom methods comes from children 
}

Is there any way to do this ? I tried but could not be implemented this. Any help is appreciated ! Thanks.

Aaronius commented 2 years ago

Hi @rizikolik, take a look at https://github.com/Aaronius/penpal/pull/50#discussion_r429646202 and let me know if it answers your question.

Aaronius commented 2 years ago

I've documented this in the readme. I'm closing this issue, but let me know if it isn't clear or doesn't answer your question. Thanks for asking.