- From: John J Barton <johnjbarton@johnjbarton.com>
- Date: Fri, 10 Feb 2012 09:00:48 -0800
- To: Ian Hickson <ian@hixie.ch>
- Cc: public-webapps <public-webapps@w3.org>
On Thu, Feb 9, 2012 at 11:53 PM, Ian Hickson <ian@hixie.ch> wrote: > On Thu, 9 Feb 2012, John J Barton wrote: >> On Thu, Feb 9, 2012 at 4:42 PM, Ian Hickson <ian@hixie.ch> wrote: >> > On Thu, 9 Feb 2012, John J Barton wrote: >> >> >> >> However the solution has two significant problems: >> >> 1. There is no way to know if portToOtherWindow is connected before >> >> you issue postMessage() >> > >> > Just have the target message you when it's ready. > > What I meant was just to do this on the receiving side (inside the > iframe), after the onmessage handler has been set up (which we are > assuming happens after the 'load' event for some reason): > > parent.postMessage('load', '*'); > > That way you don't have to depend on the 'load' event, you can just wait > for the message from the inner frame. Then when you get it, you know you > can start sending.. The problem here is that the iframe may issue parent.postMessage('load', '*") before the parent onmessage handler has been set up. Modern apps no longer use single-point synchronization. The parent window 'load' event has no time relation to the onmessage handler setup, neither the iframe load event. Instead we have multiple synchronizations based on the dependency relationships. This started with script loading but eventually all content will be loaded this way. In the past I've created synchronization in the parent by making the iframe loading dependent upon the onmessage handler set up. But this complicates and thus constraints the design. A peer-to-peer or symmetric solution would be better. > > And when you do send, you just send a message whose contents are just a > single key saying what API endpoint you want, and a port, which you then > use for all communication for that particular API call. Just to clarify, I want to see the layer you just outlined be standard so we can design iframe components and apps to mix and match. This can be two simple layers on the current messaging: 1) the connection ceremony, 2) the key/API format. > > No races or anything. Unfortunately for devs, the Web app world is becoming asynchronous. jjb > > -- > Ian Hickson U+1047E )\._.,--....,'``. fL > http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,. > Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Received on Friday, 10 February 2012 17:01:19 UTC