Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish/Subscribe across iframes #97

Open
Naethyn opened this issue Apr 22, 2014 · 4 comments
Open

Publish/Subscribe across iframes #97

Naethyn opened this issue Apr 22, 2014 · 4 comments

Comments

@Naethyn
Copy link

Naethyn commented Apr 22, 2014

It would be very useful to be able to pub/sub across iframes. I currently use amplify for most of my project, but I have to use another solution for pub/sub across iframes. Thanks!

@ifandelse
Copy link

@Naethyn I'm interested in hearing what you're using for pub/sub across frames. Amplify's pub/sub doesn't current support that, unfortunately. I have a messaging lib (postal.js) that supports cross frame and web worker communications if you use the federation add-ons to enable it (postal.federation and postal.xframe). I've used xframe quite a bit, and @dcneiner has as well. Piping a local pub/sub lib to window.postMessage isn't terribly hard in and of itself - I've found the complexity comes into play with things like the timing of the handshake between the two windows, as well as properly filtering and identifying messages and their origin so that the same messages aren't replayed in a window, etc. If you glance at xframe's code, the stuff that actually touches window.postMessage and addEventListener("message") is only a few lines, the rest address (mostly) the stuff I just mentioned.

@Naethyn
Copy link
Author

Naethyn commented Apr 22, 2014

I am making a Mobile Chrome App which uses iframes to encapsulate sandboxes (views). Currently, I am using pkg to communicate via iframes: http://burkeholland.github.io/pkg/
It works, I just wish amplify had the functionality. Thanks for the reply!

@ifandelse
Copy link

@Naethyn seems like you could potentially bridge pkg and amplify and just use pkg as the bridge/pseudo-transport between windows. Your components would publish and subscribe via amplify, and you could monkey patch amplify's subscribe and publish methods to set up subscriptions and publish messages to remote windows via pkg....that way your app only deals with amplify, and pkg is treated as pure infrastructure. I should insert a disclaimer, I work with Burke but haven't used pkg so it's possible this idea wouldn't work.... :-)

@apuchkov
Copy link

I just also faced a need to send event to iFrame

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants