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

sw-background-sync-queue #72

Merged
merged 107 commits into from
Dec 5, 2016
Merged

sw-background-sync-queue #72

merged 107 commits into from
Dec 5, 2016

Conversation

prateekbh
Copy link
Collaborator

R: @jeffposnick @addyosmani @wibblymat @gauntface @ebidel

sw-background-sync-queue library review

jeffposnick and others added 30 commits September 25, 2016 22:25
* Deploy to GitHub Pages

* First attempt at jsdoc integration

* Just removing docs for now - creates a lot of noise

* Fixing linting issues
* Deploy to GitHub Pages

* Removing jsdoc and docs

* Fixes unit tests

* Adding browser download to gulpfile

* Minor console log tweak

* Updating selenium assistant to make gulp download work
* First attempt and minified build

* Removing old modules
* Changing minification for babili

* External sourcemap and tidy up of code

* Adding license header file

* Removing unused dep
* Pulling out minified JS Bundle

* Moving to shared build config. Still needs some work

* Moving to modular gulp taks and shared build

* Removing travis typo

* Removing travis TODO
* WIP

* Some more updates to match the latest spec

* Latest sw-routing updates

* Latest sw-runtime-caching updates

* Add .min. to output .js file

* Broadcast cache update changes

* Use .bind() to ensure this is set inside of callback

* Syntax tweaks

* Demo updates

* CacheWrapper => RequestWrapper

* CacheWrapper => RequestWrapper

* Lint cleanup
JSDoc for the sw-broadcast-cache-update project.
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

Copy link
Contributor

@jeffposnick jeffposnick left a comment

Choose a reason for hiding this comment

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

Some high-level comments:

We're preferring const over let elsewhere in the project, so it would be good to switch those except for cases where you need let.

There are a ton of things that should be picked up via linting, and I'm not flagging those now.

@@ -31,7 +31,7 @@ gulp.task('download-browsers', function() {
});
});

gulp.task('test', ['download-browsers'], () => {
gulp.task('test', ['download-browsers'], () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove extra space.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,2 @@
# sw-background-sync-queue
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, you can run gulp documentation:projects --project=sw-background-sync-queue to generate some meaningful content for this file and then commit that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i'll keep this for the end, cuz i guess this needs me to write jsDoc for all

limitations under the License.
*/

/*
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the double license comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,46 @@
<html>
Copy link
Contributor

Choose a reason for hiding this comment

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

There are various linting things here that would need to be cleaned up—putting the script in an external .js file will make that easier, since you can lint that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

still skipping demo folder, this will be scrapped in the end

* @param {Object=} broadcastChannel
* @param {Object=} dbname
*/
async function initialize({broadcastChannel, dbName}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using the assert library to validate these parameters if they're required.

Copy link
Collaborator Author

@prateekbh prateekbh Nov 30, 2016

Choose a reason for hiding this comment

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

they are not required params, how do i assert them?
with simple ifs?

*
* @memberOf Queue
*/
async getRequestFromQueue(hash) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using the assert library to validate these parameters if they're required.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

*
* @memberOf Queue
*/
async getRequestFromQueue(hash) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you switch to using an anonymous object with named properties instead of position parameters?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

* @memberOf Queue
*/
async getRequestFromQueue(hash) {
if(this._queue.indexOf(hash)===-1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This would be more readable if refactored as

if(this._queue.includes(hash)) {
  return this._idbQHelper.get(hash);
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

}

get queue() {
return Object.assign([], this._queue);
Copy link
Contributor

Choose a reason for hiding this comment

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

It's odd seeing Object.assign() used for a [] target.

What's going on here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

returning a copy of the existing queue, making sure that any operations on the returned object should not polute the the private variable.
i guess i should add a comment about the same

let _idbQHelper = getDb();
// TODO: change desrialization of headers
idbObject.response = {
headers: JSON.stringify(response.headers),
Copy link
Contributor

Choose a reason for hiding this comment

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

See my previous comment about deserialization.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done and removed TODO

@jeffposnick
Copy link
Contributor

Thanks for making those changes and addressing my feedback!

Is there anything else that you'd like to finish up prior to doing an initial merge? I'm fine with getting what's currently written into the master branch and then iterating from there.

(There are some style differences in your code that's not being flagged by our current linting setup. I don't think that's something you need to address in this PR, but something that can be addressed in a later PR that tightens our linting rules.)

@prateekbh
Copy link
Collaborator Author

@jeffposnick Yay! Thanks for approving.
I guess it'll be best if we merge this and then I send smaller PRs over this :)

@jeffposnick jeffposnick merged commit 879e12e into GoogleChrome:master Dec 5, 2016
@addyosmani addyosmani modified the milestone: Service Worker Framework (beta) Feb 18, 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.

5 participants