Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #28828

Re: Promise and postMessage

From Martin Honnen <mahotrash@yahoo.de>
Newsgroups comp.lang.javascript
Subject Re: Promise and postMessage
Date 2015-10-17 12:18 +0200
Organization Liberty Development
Message-ID <mvt78p$klk$1@news.albasani.net> (permalink)
References <ec087$56217102$6def49cc$20239@nntpswitch.blueworldhosting.com>

Show all headers | View raw


Cezary Tomczyk wrote:
> I use the Promise and postMessage together. Here is the example:
>
> http://www.ctomczyk.pl/lab/postmessage/
>
> Instead of getting two different responses in two different Promises,
> I've got same response in two Promises from postMessage. See developer
> console.
>
> Why am I getting same response in two Promises when I see two different
> data send from iframe?

I have tried now with Microsoft Edge, I think the problem is that a 
sequence of code is for example

- [createIframe] init
- [createIframe] onLoad
- [processPromise] [object Object]
- [processPromise] [object Object]

At that state you have two event listeners set up for the 'message' 
event and then the first message from the iframe is received by both 
event listeners and as the event listeners call 'resolve' both the first 
Promise as well as the second are fulfilled by the same message. And as 
you remove the event listeners you do not even see the second message.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Promise and postMessage Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2015-10-16 23:50 +0200
  Re: Promise and postMessage Martin Honnen <mahotrash@yahoo.de> - 2015-10-17 11:34 +0200
    Re: Promise and postMessage Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2015-10-17 20:17 +0200
  Re: Promise and postMessage Martin Honnen <mahotrash@yahoo.de> - 2015-10-17 12:18 +0200
    Re: Promise and postMessage Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2015-10-17 21:06 +0200
    Re: Promise and postMessage Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2015-10-18 22:39 +0200

csiph-web