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

remove old callbacks in Request.JSONP.request_map #1315

Merged
merged 2 commits into from
Aug 12, 2015

Conversation

SergioCrisostomo
Copy link
Member

fixes #1293

Add option to remove old Request.JSONP.request_map callbacks. Defaults to false to be BC.

@DimitarChristoff
Copy link
Member

since that's not official API (the stored responses) BC should be ignored
and data should be removed by default. anyone who's augmented it to use
request_map to cache results clearly know what they are doing and can
adjust their code accordingly imo.

On Tuesday, August 11, 2015, Sergio Crisostomo notifications@github.com
wrote:

fixes #1293 #1293

Add option to remove old Request.JSONP.request_map callbacks. Defaults to

false to be BC.

You can view, comment on, or merge this pull request online at:

#1315
Commit Summary

  • remove old callbacks in Request.JSONP.request_map

File Changes

Patch Links:


Reply to this email directly or view it on GitHub
#1315.

Dimitar Christoff

"JavaScript is to JAVA what hamster is to ham"
@D_mitar - https://github.com/DimitarChristoff

@arian
Copy link
Member

arian commented Aug 11, 2015

Agreed with @DimitarChristoff

@SergioCrisostomo
Copy link
Member Author

Nice feedback! will update soonish and ping back.

@SergioCrisostomo
Copy link
Member Author

@@ -119,19 +119,20 @@ Request.JSONP = new Class({
return !!this.running;
},

clear: function(){
clear: function(index){
Copy link
Member

Choose a reason for hiding this comment

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

Hmmm.

What if the index isn't passed in? If it's required, that's a breaking change.

What if the index passed in isn't the running request?

Copy link
Member

Choose a reason for hiding this comment

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

it's not breaking because worst case scenario, it will just try to delete an undefined property.

I have a better fix which does not change the API - storing the index within the script tag, then auto deleting

http://jsfiddle.net/dimitar/frxnqj5q/1/

Copy link
Member

Choose a reason for hiding this comment

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

Good stuff. Might suggest we used data-jsonp-index or something rather than the element attribute, but whatever, it doesn't matter really.

Copy link
Member

Choose a reason for hiding this comment

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

i considered it but it's so short lived - initially even thought of storage but that meant storage gc when element is removed. i'd agree about data-prop as it ought to be slightly cheaper.

Copy link
Member

Choose a reason for hiding this comment

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

easier fix still. one liner

    Request.JSONP.request_map['request_' + index] = function(){
        delete Request.JSONP.request_map['request_' + index];
        this.success(arguments, index);
    }.bind(this);

so
+ delete Request.JSONP.request_map['request_' + index];

@SergioCrisostomo
Copy link
Member Author

Updated again. No index anymore and using Dimitar's oneliner, much better idea.

@DimitarChristoff
Copy link
Member

@SergioCrisostomo
Copy link
Member Author

Nice! Yeah, that index was already there from before and is unused. Will cherry pick your work and use it. thanks!

Sent from my iPhone

On 12 aug 2015, at 12:19, Dimitar Christoff notifications@github.com wrote:

@SergioCrisostomo check master...DimitarChristoff:SergioCrisostomo-fix1293 - missed an index and such.


Reply to this email directly or view it on GitHub.

SergioCrisostomo added a commit that referenced this pull request Aug 12, 2015
remove old callbacks in Request.JSONP.request_map
@SergioCrisostomo SergioCrisostomo merged commit 5f286e7 into mootools:master Aug 12, 2015
@mootools mootools deleted a comment Jun 1, 2018
@mootools mootools deleted a comment Feb 13, 2019
@mootools mootools deleted a comment Jul 15, 2019
@mootools mootools deleted a comment Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants