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

Skip pending request if new content is set #24

Merged
merged 4 commits into from
Mar 27, 2017
Merged

Conversation

tomalec
Copy link
Member

@tomalec tomalec commented Mar 23, 2017

@tomalec tomalec requested a review from warpech March 23, 2017 14:52
juicy-html.html Outdated
*/
JuicyHTMLPrototype.skip = function() {
if(this.pending){
this.pending.onload = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you consider this.pending.abort();?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did. But since we cannot even mimic such abort with HTML imports, I'd rather keep both element consistent.

juicy-html.html Outdated
* Skips/disregards pending request if any
* @return {XMLHttpRequest} skipped XHR request, in fact just `this.pending`
*/
JuicyHTMLPrototype.skip = function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since _loadExternalFile is "private", maybe this method should be called _skip (with an underscore)? Or maybe a fuller name _abortLoadingExternalFile().

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's worth keeping it private, as stracounter-include may use it.

Copy link
Contributor

@warpech warpech Mar 23, 2017

Choose a reason for hiding this comment

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

You mean keeping it public?

Anyway I opt for more informative method name, like abortLoadingExternalFile. And I suggest to not return anything, since nowhere you are using the return value (YAGNI).

Copy link
Member Author

@tomalec tomalec Mar 24, 2017

Choose a reason for hiding this comment

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

Yes "keeping it public" sorry.

I don' like abort... as we are not aborting the loading of external file, what about skipStampingPendingFile?

Personally, I don't like YAGNI approach, especially in the world where we don't have any requirements and all we do is foreseeing potential applications.
Also from functional, mathematical point of view I prefer functions that returns something. They are easier to test and comprehend.

However if you are really on it, I may remove this return

Copy link
Contributor

Choose a reason for hiding this comment

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

You prefer them, because they are harder to test and comprehense? For this reason I don't prefer them, sorry :P

Copy link
Contributor

Choose a reason for hiding this comment

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

skipStampingPendingFile is also ok for me.

The fact that I has confused about what does this method do proves that just calling it skip is not enough. "Skip what?" is the question that I want to be answered by the method name.

Copy link
Member Author

Choose a reason for hiding this comment

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

You prefer them, because they are harder to test and comprehense? For this reason I don't prefer them, sorry :P

Sorry, I meant

Also from functional, mathematical point of view I prefer functions that returns something. They are easier to test and comprehend.

Copy link
Contributor

@warpech warpech Mar 24, 2017

Choose a reason for hiding this comment

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

I don't think they are easier to test, because you have one more thing to test - the return value.

And none of the existing tests checks it.

@tomalec tomalec force-pushed the skip-when-url-changed branch from f2202cd to de2d961 Compare March 24, 2017 13:50
@tomalec
Copy link
Member Author

tomalec commented Mar 24, 2017

@warpech What about now?

Copy link
Contributor

@warpech warpech left a comment

Choose a reason for hiding this comment

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

LGTM

@tomalec tomalec merged commit e1df391 into master Mar 27, 2017
@tomalec tomalec deleted the skip-when-url-changed branch March 27, 2017 13:00
tomalec added a commit to Juicy/imported-template that referenced this pull request Mar 27, 2017
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

Successfully merging this pull request may close these issues.

None yet

2 participants