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

Iframe transport #2

Merged
merged 24 commits into from
Jun 5, 2014
Merged

Iframe transport #2

merged 24 commits into from
Jun 5, 2014

Conversation

bkoval
Copy link
Contributor

@bkoval bkoval commented May 23, 2014

No description provided.

* @param {Event} event
*/
function onMessage(event){
if (event.data.match(PROTOCOL_NAME + '.request')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't see an easier alternative to constructing dispatcher for the internal use and analyzing the stringified hash before parsing by dispatcher. Is there any better way?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm for as long as someone won't put PROTOCOL_NAME + '.request' somewhere in a payload


/**
* Returns a valid communication protocol for native platform
* @returns {*|{request: request, response: response}}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add more description here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Described below.

* @param {Event} event
*/
function onMessage(event) {
if (event.data && event.data.protocol === PROTOCOL_NAME) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event.data is used couple of times here, consider caching it in local variable

*/
function iframeProtocol () {
return {
request: function (execContext, target, method, params, callbackId, async) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about using object with params instead of 6 function arguments ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One todo added with invoke method + ticket for refactoring :)

@RafLeszczynski
Copy link

except the missing white space 👍 @hakubo please take a second look :-)

@hakubo
Copy link
Contributor

hakubo commented May 30, 2014

oh right
Do you have a way to test it around?
in different combinations?

looking good - if works :)

@hakubo
Copy link
Contributor

hakubo commented May 30, 2014

plus could you document it a little how to use it on both sides?

thanks

@bkoval
Copy link
Contributor Author

bkoval commented May 30, 2014

Sure thing, will add an example and documentation to the readme + would love to make a sanity check on both Android and iOS devices if this doesn't spoil anything there ;)

@hakubo
Copy link
Contributor

hakubo commented May 31, 2014

🙇

((callbackId) ? '&callbackId=' + encodeURIComponent(callbackId) : '');
} else {
throw "Context doesn't support User Agent location API";
locationError();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proxying the exception will report the line inside locationError as the source, I'd suggest to create a LocationException type and throw here, it achieves the same goal but reports the correct line in the source.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally right!

@federico-lox
Copy link
Contributor

Good job! I've left a couple inline remarks and I'll keep my fingers crossed for the results of getting this for a ride on real devices ⏩

@bkoval
Copy link
Contributor Author

bkoval commented Jun 2, 2014

Ok, verified as working on iOS, with a little patch for a bug we found (see object.keys commit) ;)

Rafal Leszczynski and others added 2 commits June 3, 2014 12:35
@bkoval
Copy link
Contributor Author

bkoval commented Jun 3, 2014

Ok, this appears to work just fine with the apps. I also added a little todo comment for refactoring a little too big number (6) of parameters in invoke method (requires changes in the app repo). @federico-lox @hakubo @RafLeszczynski if you're not waving red flags, i would love to merge it ;)

@federico-lox
Copy link
Contributor

Hey @bkoval, there are still a couple of requests from the participants to improve both the readme and the inline documentation, I think it's worth addressing those before merging since this is an open source project.

Let's make a deal, you address those and we wave a big green flag 😉
green flag

@bkoval
Copy link
Contributor Author

bkoval commented Jun 5, 2014

Docs updated, mergin' ;)

bkoval added a commit that referenced this pull request Jun 5, 2014
@bkoval bkoval merged commit 6ea77bc into master Jun 5, 2014
@hakubo hakubo deleted the iframe-transport branch June 5, 2014 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants