Giter Site home page Giter Site logo

Comments (3)

Aaronius avatar Aaronius commented on May 18, 2024

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.

loganvolkers avatar loganvolkers commented on May 18, 2024

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.

Aaronius avatar Aaronius commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.