Comments (3)
This would be a fantastic contribution. Thank you for offering. Contributing guidelines:
Try to follow the conventions already in the code. Don't be offended if I tweak it later.
File size is a feature. Consider it as such.
Add tests where you can (looks like you already have the idea).
Thanks!
from penpal.
Well shoot. My fix of adding a childId
didn't fix my test. Turns out the problem was in my test code.
Here's the revised test code:
it('should call an asynchronous function on the child, but only the right child!', (done) => {
const c1 = Penpal.connectToChild({
url: `http://${HOST}:9000/child.html`
});
const c2 = Penpal.connectToChild({
url: `http://${HOST}:9000/child.html`
});
c1.promise.then((child) => {
child.multiplyAsync(2, 5).then((value) => {
expect(value).toEqual(10);
c1.destroy();
done();
});
});
c2.promise.then((child) => {
child.multiplyAsync(3, 5).then((value) => {
expect(value).toEqual(15);
c2.destroy();
done();
});
});
});
Also today I learned that using event.source
and data.id
already provides adequate filtering for this use case.
if (event.source === remote &&
event.origin === remoteOrigin &&
event.data.penpal === REPLY &&
event.data.id === id) {
Thanks for the prompt response! Looking forward to using Penpal for more.
from penpal.
This test has been added to the test suite: 3e61c23
I tweaked it a bit to make sure done
will only get called after both method calls resolve.
from penpal.
Related Issues (20)
- Compatibility v4-v5 HOT 2
- Latest chrome update breaks the penpal HOT 2
- TypeScript imports with Penpal 5.2.0 HOT 6
- Serializing Objects with Functions causes an error HOT 3
- Provide typing for Connection HOT 1
- How to detect if connection with child was lost? HOT 11
- Option to skip iframe validation? HOT 6
- Remove check that determines if `connectToParent` is running inside iframe HOT 1
- Iframe Removal Monitoring not Working with Custom Elements HOT 7
- Export types HOT 6
- Types for the response of Promise returned after connection established HOT 2
- dynamic iframe url HOT 3
- Make parentOrigin on connectToParent required
- Including penpal in babel producing errors HOT 1
- Examples for using with React Hooks HOT 4
- error "Cannot read properties of null (reading 'postMessage')" HOT 9
- Question: Why does penpal use Window#postMessage instead of MessageChannel? HOT 2
- connected fail HOT 2
- [Penpal] Parent: Awaiting handshake
- Feature request: allow subdomains of childOrigin HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from penpal.