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

Refactorings #124

Open
wants to merge 2 commits into
base: feature/eslint
Choose a base branch
from
Open

Refactorings #124

wants to merge 2 commits into from

Conversation

el1t
Copy link
Contributor

@el1t el1t commented Jun 12, 2017

I don't think this is how pull requests work

  • Combine font requests
  • Update readme
  • ApiHandler to class
  • app.use api/renderer after static resources

const XHR = new XMLHttpRequest()
XHR.open("POST", "")
XHR.setRequestHeader("Content-Type", "application/json")
const xhr = new XMLHttpRequest()
Copy link
Contributor

Choose a reason for hiding this comment

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

so i get why you changed this, and that's totally fine, but for some reason most places make XHR capitalized because its an acronym /shrug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't actually know or have an opinion on which it's supposed to be, but was following @bluepichu's comments on #123

Copy link
Contributor

Choose a reason for hiding this comment

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

The general convention I've seen (outside the JS API) is that acronyms are single words, and thus get camel-cased as such. So you would have xhr and createNewXhr, for example. We could go a different way if you feel strongly.

Copy link
Contributor

@zwade zwade left a comment

Choose a reason for hiding this comment

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

Looks mostly good, just have a few concerns

window.getSelection().empty ? window.getSelection().empty() : undefined
window.getSelection().removeAllRanges ? window.getSelection().removeAllRanges() : undefined
window.getSelection().addRange(range)
const $copyBuffer = $("#copy-buffer")
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like the use of $ to prefix the variable name. What is the rationale? Is it just to indicate that it's a jquery object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah pretty much, and helps avoid colliding names with existing vars

Copy link
Contributor

Choose a reason for hiding this comment

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

ehhhh, I would rather not have it (perhaps because so many languages use that syntax to denote that something is a variable at all). @bluepichu tiebreaker?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also avoid it unless you feel very strongly.

@@ -1,59 +1,39 @@
"use strict"

const denodeify = require("denodeify")
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work? In the past i haven't been able to use denodeify because it was screwing up the prototypical ownership.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh idk perhaps not 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

mmmm you should test it lol

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or would util.promisify work?

}
})(handle)
}
ApiHandler.routes = Object.freeze({
Copy link
Contributor

Choose a reason for hiding this comment

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

@bluepichu can I get another pair of eyes on this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's fine, but I'm getting myself confused lol

Copy link
Contributor

Choose a reason for hiding this comment

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

...I don't get why we need to freeze but it otherwise looks reasonable

const globals = {}
globals.coll = undefined
globals.path = undefined

function denodeify(fn, args, alt, th) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same question as before

Copy link
Contributor Author

Choose a reason for hiding this comment

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

at the very least I can pull them into utils and probably rename it to avoid confusion

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah that'd be fine

@el1t
Copy link
Contributor Author

el1t commented Jun 12, 2017

Regarding combining the font requests: the CSS file is only cached for 1 day, while the font is cached for a year. Combining them in theory reduces cache hits, but the lifetime is so short it probably doesn't matter.

@zwade
Copy link
Contributor

zwade commented Jun 12, 2017

Interesting, how do you get those numbers?

@el1t
Copy link
Contributor Author

el1t commented Jun 12, 2017

From here:

Requests for CSS assets are cached for 1 day.
...
The font files themselves are cached for one year, which cumulatively has the effect of making the entire web faster: When millions of websites all link to the same fonts, they are cached after visiting the first website and appear instantly on all other subsequently visited sites.

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.

3 participants