{"action":"created","issue":{"url":"https://api.github.com/repos/zalmoxisus/crossmessaging/issues/2","labels_url":"https://api.github.com/repos/zalmoxisus/crossmessaging/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/zalmoxisus/crossmessaging/issues/2/comments","events_url":"https://api.github.com/repos/zalmoxisus/crossmessaging/issues/2/events","html_url":"https://github.com/zalmoxisus/crossmessaging/issues/2","id":129506729,"number":2,"title":"Using crossmessaging from an external iframe (not in any extension/app package)","user":{"login":"bmenant","id":756887,"avatar_url":"https://avatars.githubusercontent.com/u/756887?v=3","gravatar_id":"","url":"https://api.github.com/users/bmenant","html_url":"https://github.com/bmenant","followers_url":"https://api.github.com/users/bmenant/followers","following_url":"https://api.github.com/users/bmenant/following{/other_user}","gists_url":"https://api.github.com/users/bmenant/gists{/gist_id}","starred_url":"https://api.github.com/users/bmenant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmenant/subscriptions","organizations_url":"https://api.github.com/users/bmenant/orgs","repos_url":"https://api.github.com/users/bmenant/repos","events_url":"https://api.github.com/users/bmenant/events{/privacy}","received_events_url":"https://api.github.com/users/bmenant/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-28T16:43:39Z","updated_at":"2016-01-28T17:26:41Z","closed_at":null,"body":"So I did the pullrequest #1 but I apparently did not finish my part of the job. :smile: \r\n\r\nWhat I’d like to achieve, is to move out the _UI_ from the extension package (in order to gain more reactivity with our release cycles for cosmetic/UX stuff). That said, I’d like to inject an iframe located somewhere else (i.e. not accessible under `chrome-extension://*`).\r\n\r\nMy concern is now the `connect` function: https://github.com/zalmoxisus/crossmessaging/blob/master/src/index.js#L36-L43\r\n\r\nI’m not going to call this function from a _background_ environment, thus I have to pass the extension id somehow. \r\nIf I relied upon this to sync the store: https://github.com/zalmoxisus/crossbuilder/blob/master/src/app/store/getStateFromBg.js#L6 I’d be stuck, since the `arg` would be set to `true` (no way to set an extension id over here). \r\nHowever, if I write a new `getStateFromBgToIframe()` (:fearful:) with something such `connect(MY_EXT_ID)`... I’m afraid it may not work out well, since `window.bgConnection` would be `undefined`. What do you think? I’ve had such trials trying to get the whole picture of those functions. Any piece of help is appreciated. :wink: \r\n\r\nBy the way, I’m wondering if `getStateFromBg()` could handle that issue as well, through a third argument or something to set an extension id?\r\n\r\nAnyway, thank you so much @zalmoxisus what you’ve accomplished here is really really helpful!\r\n"},"comment":{"url":"https://api.github.com/repos/zalmoxisus/crossmessaging/issues/comments/176291962","html_url":"https://github.com/zalmoxisus/crossmessaging/issues/2#issuecomment-176291962","issue_url":"https://api.github.com/repos/zalmoxisus/crossmessaging/issues/2","id":176291962,"user":{"login":"zalmoxisus","id":7957859,"avatar_url":"https://avatars.githubusercontent.com/u/7957859?v=3","gravatar_id":"","url":"https://api.github.com/users/zalmoxisus","html_url":"https://github.com/zalmoxisus","followers_url":"https://api.github.com/users/zalmoxisus/followers","following_url":"https://api.github.com/users/zalmoxisus/following{/other_user}","gists_url":"https://api.github.com/users/zalmoxisus/gists{/gist_id}","starred_url":"https://api.github.com/users/zalmoxisus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalmoxisus/subscriptions","organizations_url":"https://api.github.com/users/zalmoxisus/orgs","repos_url":"https://api.github.com/users/zalmoxisus/repos","events_url":"https://api.github.com/users/zalmoxisus/events{/privacy}","received_events_url":"https://api.github.com/users/zalmoxisus/received_events","type":"User","site_admin":false},"created_at":"2016-01-28T17:26:41Z","updated_at":"2016-01-28T17:26:41Z","body":"The purpose of this lib is to have an API, which will be easy to extend for Firefox and Safari extension. What you what to achieve wouldn't be crossbrowser, so if you want to follow this way it would be simplier to use direct chrome API.\r\n\r\nI don't know too much about your usercase, but I think it would be way better to communicate between page script and extension's content script via `window.postMessage` instead. It would be more stable and could be extended to be crossbrowser."}}